@arcgis/core 4.33.0-next.20250205 → 4.33.0-next.20250206
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.
- package/assets/components/assets/icon/dualImageArea16.json +1 -0
- package/assets/components/assets/icon/dualImageArea24.json +1 -0
- package/assets/components/assets/icon/dualImageArea32.json +1 -0
- package/assets/components/assets/icon/dualImageDistance16.json +1 -0
- package/assets/components/assets/icon/dualImageDistance24.json +1 -0
- package/assets/components/assets/icon/dualImageDistance32.json +1 -0
- package/assets/components/assets/icon/dualImageLocation16.json +1 -0
- package/assets/components/assets/icon/dualImageLocation24.json +1 -0
- package/assets/components/assets/icon/dualImageLocation32.json +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{24a86c52c8bdd0b5eb4d.js → 09a99c556089c166d1f8.js} +1 -1
- package/assets/esri/core/workers/chunks/15f850c9a1154fc57e5a.js +1 -0
- package/assets/esri/core/workers/chunks/{9b4f471fcd8a3b5e089f.js → 192569dfa7c0ea8dd864.js} +1 -1
- package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/24e47f748f0e4f815c6e.js +1 -0
- package/assets/esri/core/workers/chunks/28374a64790342e1b5ae.js +1 -0
- package/assets/esri/core/workers/chunks/{ad215219e5eef8598745.js → 28dbbfc44cc2bdcd221d.js} +1 -1
- package/assets/esri/core/workers/chunks/2adc533dadcb018a9755.js +1 -0
- package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/333091ab2e267652ed56.js +1 -0
- package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/38cd7745b8ef1b8b6196.js +1 -0
- package/assets/esri/core/workers/chunks/{8a1e4f65fc81aba7a704.js → 4122d10bc910e888eee1.js} +1 -1
- package/assets/esri/core/workers/chunks/433576983754f690bcc7.js +1 -0
- package/assets/esri/core/workers/chunks/{b1269b51cef3e11c85e3.js → 48ecc5a74fecbb2b9c6f.js} +1 -1
- package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js → 5a25cef6355fd20e44e7.js} +2 -2
- package/assets/esri/core/workers/chunks/{6d5bfcc7856cafe7b043.js.LICENSE.txt → 5a25cef6355fd20e44e7.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/{7a0415db78c68d31733f.js → 6039da57a2adedd3b83f.js} +1 -1
- package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/73d03c208242778e67bf.js +1 -0
- package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/{723a9fba144e2fa6d017.js → 7cb09e58bcc537ec1f7a.js} +1 -1
- package/assets/esri/core/workers/chunks/842db06ce62758fab1e7.js +1 -0
- package/assets/esri/core/workers/chunks/{610b33b7291cffcc4e5d.js → a42ae5d5e5f66d120b4d.js} +1 -1
- package/assets/esri/core/workers/chunks/a5e9ea13e844a62b2a7f.js +1 -0
- package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
- package/assets/esri/core/workers/chunks/b43d88b6e7dc4ab13599.js +1 -0
- package/assets/esri/core/workers/chunks/{9c5c6ecaf5be24279fa5.js → ddc30044f61a2c2df3fe.js} +1 -1
- package/assets/esri/core/workers/chunks/ef6279f5c63ab1e88c71.js +1 -0
- package/assets/esri/core/workers/chunks/{0711d3ad4d403bcfdcad.js → f117a89d1f4001a1f9f0.js} +1 -1
- package/assets/esri/core/workers/chunks/f9e48205178a5a804d38.js +1 -0
- package/assets/esri/themes/base/widgets/_Directions.scss +15 -6
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/WaterSurface.glsl.js +2 -2
- package/geometry/operators/projectOperator.js +1 -1
- package/geometry/operators/shapePreservingProjectOperator.js +1 -1
- package/geometry/support/meshUtils/elevation.js +1 -1
- package/interfaces.d.ts +63 -28
- package/layers/Layer.js +1 -1
- package/layers/graphics/data/FeatureStore.js +1 -1
- package/layers/ogc/wcsUtils.js +1 -1
- package/layers/support/RasterFunctionTemplate.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/multipartParser.js +1 -1
- package/layers/support/rasterDatasets/wcsCapabilitiesParser.js +1 -1
- package/layers/support/rasterFunctionUtils.d.ts +2 -1
- package/layers/support/rasterFunctionUtils.js +1 -1
- package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
- package/package.json +2 -2
- package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
- package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolRasterizer.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapResources.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/GraphicsLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/LayerView2D.js +1 -1
- package/views/2d/layers/MapImageLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/graphics/HighlightGraphicContainer.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/support/util.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
- package/views/LayerViewManager.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileCache.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
- package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/assets/esri/core/workers/chunks/380d37ceb8cf52bad190.js +0 -1
- package/assets/esri/core/workers/chunks/39e38aab86dcee3f79be.js +0 -1
- package/assets/esri/core/workers/chunks/69d307758262e5d7a32e.js +0 -1
- package/assets/esri/core/workers/chunks/7e4d72279cc599b7029c.js +0 -1
- package/assets/esri/core/workers/chunks/8438fba57e82e4cc7c11.js +0 -1
- package/assets/esri/core/workers/chunks/858b191c078d04232342.js +0 -1
- package/assets/esri/core/workers/chunks/92155d112ebb6a4c6c6e.js +0 -1
- package/assets/esri/core/workers/chunks/b33122adfd1fb68f7c0f.js +0 -1
- package/assets/esri/core/workers/chunks/bbbe5d6cb8b737811c84.js +0 -1
- package/assets/esri/core/workers/chunks/bf26f58210755875748c.js +0 -1
- package/assets/esri/core/workers/chunks/d8c762ca94e3a11b125d.js +0 -1
- package/assets/esri/core/workers/chunks/dbc447413ab40a79ba87.js +0 -1
- package/assets/esri/core/workers/chunks/e410a09650530d7aad10.js +0 -1
package/widgets/Directions.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{isSome as t}from"../core/arrayUtils.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as s,initial as o,on as r}from"../core/reactiveUtils.js";import{escapeRegExpString as a}from"../core/string.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import c from"../portal/Portal.js";import{defaultUnitPropertyMetadata as d}from"../properties/defaultUnit.js";import m from"../rest/support/Stop.js";import p from"../symbols/SimpleMarkerSymbol.js";import u from"./Search.js";import h from"./Widget.js";import{DirectionsSearchTool as v}from"./Directions/DirectionsSearchTool.js";import g from"./Directions/DirectionsViewModel.js";import _ from"./Directions/DirectionsVisibleElements.js";import{formatDistance as w,formatDuration as y,DepartureTimeOption as b,getIconName as f}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as S,meteredArcGISLocatorUrl as M}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as k}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";function T(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,n,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>a(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let u=0;const h=[];for(const{0:t,index:a}of p)h.push(s.slice(u,a),x("span",{class:$.labelEmphasize,key:`maneuver-${a}`},t)),u=a+t.length;return h.push(s.slice(u)),x("span",{id:`key-${l}`},h)}function C(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const D="esri-directions",$={base:D,accordion:`${D}__accordion`,actionContainer:`${D}__action-container`,departureTimeOptions:`${D}__departure-time-options`,directionsHeader:`${D}__directions-header`,directionsHeaderStopName:`${D}__directions-header-stop-name`,editFooter:`${D}__edit-footer`,editToolbar:`${D}__edit-toolbar`,editToolbarContainer:`${D}__edit-toolbar-container`,flexColumn:`${D}__flex-column`,flexRow:`${D}__flex-row`,headerStops:`${D}__header-stops`,labelEmphasize:`${D}__label-emphasize`,labelNoBottomMargin:`${D}__label-no-bottom-margin`,marginInlineMedium:`${D}__margin-inline-medium`,paddingMedium:`${D}__padding-medium`,primaryFlowItem:`${D}__primary-flow-item`,primaryFooter:`${D}__primary-footer`,primaryFooterCentered:`${D}__primary-footer-centered`,routeItem:`${D}__route-item`,routeItemButton:`${D}__route-item-button`,routeItemButtonContent:`${D}__route-item-button-content`,routeItemLabel:`${D}__route-item-label`,routeItemDescription:`${D}__route-item-description`,saveError:`${D}__save-error`,saveErrorIcon:`${D}__save-error-icon`,saveErrorLabel:`${D}__save-error-label`,saveProcessLoader:`${D}__save-process-loader`,selectedFeatureContainer:`${D}__selected-feature-container`,separator:`${D}__separator`,stopContainer:`${D}__stop-container`,stopItem:`${D}__stop-item`};let L=class extends h{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=[new m,new m],this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new g,this.visibleElements=new _}initialize(){this.addHandles([s((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),o),s((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),o)])}loadDependencies(){return k({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),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"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new u({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([r((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),s((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return x("div",{class:this.classes($.base,I.widget,I.panel)},x("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",S(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=M))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:w(s,t,o),duration:y(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new v({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=c.getDefault();try{await e.signIn()}catch(t){if(i(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return x("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return x("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=b;return x("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,x("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},x("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),x("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),x("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==b.DEPART_AT?null:x("div",{class:$.departureTimeOptions},x("calcite-input-date-picker",{scale:"s",valueAsDate:C(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),x("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return x("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},x("div",{class:$.directionsHeader,slot:"header-content"},x("div",{class:$.headerStops},x("span",null,this.messages.from)," ",x("span",{class:$.directionsHeaderStopName},o),x("span",null,this.messages.to)," ",x("span",{class:$.directionsHeaderStopName},r)),x("div",{class:$.flexColumn},x("span",null,`${i} (${t})`),s?x("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),x("calcite-accordion",{class:$.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return x("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},x("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return x("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=w(this.messagesUnits,o??0,this.unit),n=y(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=T(i),d=f(i.directionPointType);return x("calcite-list-item",{class:$.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},x("calcite-icon",{icon:d,slot:"content-start"}),x("div",{slot:"content"},x("calcite-label",{layout:"inline",scale:"s"},c),x("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},x("div",{class:$.flexColumn,key:"edit-container"},x("div",{class:$.editToolbarContainer},x("div",{class:$.editToolbar},x("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),x("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),x("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),x("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),x("div",{class:$.selectedFeatureContainer},x("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>x("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},x("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),x("div",{class:$.editFooter},x("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return x("div",{class:$.primaryFooter,key:"footer-missing-layer"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return x("div",{class:$.primaryFooterCentered,key:"footer-sign-in"},x("calcite-label",null,this.messages.signInRequired),x("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return x("div",{class:$.primaryFooter,key:"footer-service-error"},x("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return x("div",{class:$.primaryFooter,key:"footer-unsolved-route"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return x("div",{class:$.primaryFooter,key:"footer-invalid-route"},x("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return x("div",{class:$.routeItem,key:"footer-directions-summary"},x("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:$.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},x("div",{class:$.routeItemButtonContent},x("span",{class:$.routeItemLabel},`${i} (${t})`),x("span",{class:$.routeItemDescription},s)),x("calcite-icon",{icon:"chevron-right",scale:"s"})),x("calcite-dropdown",null,x("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return x("div",{class:$.actionContainer,key:"interactive-route-action-container"},x("calcite-button",{appearance:"outline",iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new p;this.viewModel.layer?.stops.add(new m({symbol:e}))}},this.messages.addStop),x("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()}},this.messages.editRoute),x("calcite-button",{appearance:"outline",bind:this,iconStart:"arrow-up-down",kind:"neutral",label:this.messages.reverseStops,onclick:()=>{this.viewModel.layer?.stops.reverse(),this._resetStopSequence(),this._solveRoute()}}))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return x("div",null,x("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,x("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[x("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,x("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),x("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,x("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return x("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},x("calcite-panel",{class:$.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return x("div",{class:$.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-error"},x("div",{class:$.saveError},x("calcite-icon",{class:$.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),x("calcite-label",{class:$.saveErrorLabel},e)),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return x("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return x("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>x("calcite-combobox-item",{heading:e.title??"",key:`${D}-folder-${e.id}`,value:e.id})));return i.unshift(x("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${D}-folder-home`,selected:!0,value:null})),x("calcite-panel",{key:"save-layer-panel"},x("div",{class:$.paddingMedium},x("calcite-label",null,this.messages.laverName,x("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),x("calcite-label",null,this.messages.saveInFolder,x("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),x("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return x("calcite-panel",{class:$.marginInlineMedium,key:"save-layer-processing"},x("calcite-loader",{class:$.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return x("div",{class:$.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this._renderDeleteStopAction(e),o=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-list-item",{key:`stop-${o}`,value:e},x("div",{class:$.flexRow,slot:"actions-end"},i,s),x("div",{class:$.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops.toArray()??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return x("div",{class:$.stopContainer,key:$.stopContainer},x("calcite-list",{dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:e})=>{this.viewModel.layer?.stops.reorder(e.dragEl.value,e.newIndex),this._resetStopSequence(),this._solveRoute()}},e.map((e=>this._renderStop(e)))))}_renderTravelModes(){return this.viewModel.travelModes.length?x("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,x("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>x("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return x("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([n()],L.prototype,"_currentFlowItem",void 0),e([n()],L.prototype,"_saveState",void 0),e([n()],L.prototype,"apiKey",null),e([n(d)],L.prototype,"defaultUnit",void 0),e([n()],L.prototype,"goToOverride",null),e([n()],L.prototype,"headingLevel",void 0),e([n()],L.prototype,"icon",null),e([n()],L.prototype,"label",null),e([n({readOnly:!0})],L.prototype,"lastRoute",null),e([n()],L.prototype,"layer",null),e([n()],L.prototype,"maxStops",null),e([n(),F("esri/widgets/Directions/t9n/Directions")],L.prototype,"messages",void 0),e([n(),F("esri/core/t9n/Units")],L.prototype,"messagesUnits",void 0),e([n()],L.prototype,"searchProperties",void 0),e([n()],L.prototype,"unit",null),e([n()],L.prototype,"view",null),e([n({type:g})],L.prototype,"viewModel",void 0),e([n({type:_,nonNullable:!0})],L.prototype,"visibleElements",void 0),L=e([l("esri.widgets.Directions")],L);const A=L;export{A as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{isAbortError as s}from"../core/promiseUtils.js";import{watch as o,initial as r,on as a}from"../core/reactiveUtils.js";import{escapeRegExpString as n}from"../core/string.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"../portal/Portal.js";import{defaultUnitPropertyMetadata as m}from"../properties/defaultUnit.js";import p from"../rest/support/Stop.js";import u from"../symbols/SimpleMarkerSymbol.js";import h from"./Search.js";import v from"./Widget.js";import{DirectionsSearchTool as g}from"./Directions/DirectionsSearchTool.js";import _ from"./Directions/DirectionsViewModel.js";import w from"./Directions/DirectionsVisibleElements.js";import{formatDistance as y,formatDuration as b,DepartureTimeOption as f,getIconName as S}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as M,meteredArcGISLocatorUrl as k}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{tsx as T}from"./support/jsxFactory.js";function C(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,a,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>n(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let u=0;const h=[];for(const{0:t,index:n}of p)h.push(s.slice(u,n),T("span",{class:L.labelEmphasize,key:`maneuver-${n}`},t)),u=n+t.length;return h.push(s.slice(u)),T("span",{id:`key-${l}`},h)}function D(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const $="esri-directions",L={base:$,accordion:`${$}__accordion`,actionContainer:`${$}__action-container`,addStopButton:`${$}__add-stop-button`,departureTimeOptions:`${$}__departure-time-options`,directionsHeader:`${$}__directions-header`,directionsHeaderStopName:`${$}__directions-header-stop-name`,editFooter:`${$}__edit-footer`,editToolbar:`${$}__edit-toolbar`,editToolbarContainer:`${$}__edit-toolbar-container`,flexColumn:`${$}__flex-column`,flexRow:`${$}__flex-row`,headerStops:`${$}__header-stops`,labelEmphasize:`${$}__label-emphasize`,labelNoBottomMargin:`${$}__label-no-bottom-margin`,marginInlineMedium:`${$}__margin-inline-medium`,paddingMedium:`${$}__padding-medium`,primaryFlowItem:`${$}__primary-flow-item`,primaryFooter:`${$}__primary-footer`,primaryFooterCentered:`${$}__primary-footer-centered`,routeItem:`${$}__route-item`,routeItemButton:`${$}__route-item-button`,routeItemButtonContent:`${$}__route-item-button-content`,routeItemLabel:`${$}__route-item-label`,routeItemDescription:`${$}__route-item-description`,saveError:`${$}__save-error`,saveErrorIcon:`${$}__save-error-icon`,saveErrorLabel:`${$}__save-error-label`,saveProcessLoader:`${$}__save-process-loader`,selectedFeatureContainer:`${$}__selected-feature-container`,separator:`${$}__separator`,stopContainer:`${$}__stop-container`,stopList:`${$}__stop-list`,stopItem:`${$}__stop-item`};let A=class extends v{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new p,new p]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new _,this.visibleElements=new w}initialize(){this.addHandles([o((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),r),o((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),r)])}loadDependencies(){return I({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),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"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new h({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([a((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),o((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return T("div",{class:this.classes(L.base,F.widget,F.panel)},T("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",M(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=k))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:y(s,t,o),duration:b(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new g({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=d.getDefault();try{await e.signIn()}catch(t){if(s(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return T("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return T("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",slot:"actions-end",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=f;return T("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,T("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},T("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),T("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),T("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==f.DEPART_AT?null:T("div",{class:L.departureTimeOptions},T("calcite-input-date-picker",{scale:"s",valueAsDate:D(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),T("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return T("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},T("div",{class:L.directionsHeader,slot:"header-content"},T("div",{class:L.headerStops},T("span",null,this.messages.from)," ",T("span",{class:L.directionsHeaderStopName},o),T("span",null,this.messages.to)," ",T("span",{class:L.directionsHeaderStopName},r)),T("div",{class:L.flexColumn},T("span",null,`${i} (${t})`),s?T("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),T("calcite-accordion",{class:L.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return T("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},T("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return T("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=y(this.messagesUnits,o??0,this.unit),n=b(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=C(i),d=S(i.directionPointType);return T("calcite-list-item",{class:L.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},T("calcite-icon",{icon:d,slot:"content-start"}),T("div",{slot:"content"},T("calcite-label",{layout:"inline",scale:"s"},c),T("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:T("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},T("div",{class:L.flexColumn,key:"edit-container"},T("div",{class:L.editToolbarContainer},T("div",{class:L.editToolbar},T("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),T("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),T("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),T("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),T("div",{class:L.selectedFeatureContainer},T("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>T("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},T("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),T("div",{class:L.editFooter},T("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return T("div",{class:L.primaryFooter,key:"footer-missing-layer"},T("calcite-notice",{icon:"information",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return T("div",{class:L.primaryFooterCentered,key:"footer-sign-in"},T("calcite-label",null,this.messages.signInRequired),T("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return T("div",{class:L.primaryFooter,key:"footer-service-error"},T("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return T("div",{class:L.primaryFooter,key:"footer-unsolved-route"},T("calcite-notice",{icon:"information",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return T("div",{class:L.primaryFooter,key:"footer-invalid-route"},T("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return T("div",{class:L.routeItem,key:"footer-directions-summary"},T("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:L.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},T("div",{class:L.routeItemButtonContent},T("span",{class:L.routeItemLabel},`${i} (${t})`),T("span",{class:L.routeItemDescription},s)),T("calcite-icon",{icon:"chevron-right",scale:"s"})),T("calcite-dropdown",null,T("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return T("div",{class:L.actionContainer,key:"interactive-route-action-container"},T("calcite-button",{appearance:"outline",class:L.addStopButton,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new u;this.viewModel.layer?.stops.add(new p({symbol:e}))},width:"half"},this.messages.addStop),T("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()},width:"half"},this.messages.editRoute))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return T("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return T("div",null,T("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,T("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[T("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,T("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),T("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,T("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return T("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},T("calcite-panel",{class:L.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return T("div",{class:L.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return T("calcite-panel",{class:L.paddingMedium,key:"save-layer-error"},T("div",{class:L.saveError},T("calcite-icon",{class:L.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),T("calcite-label",{class:L.saveErrorLabel},e)),T("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return T("calcite-panel",{class:L.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:T("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return T("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return T("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>T("calcite-combobox-item",{heading:e.title??"",key:`${$}-folder-${e.id}`,value:e.id})));return i.unshift(T("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${$}-folder-home`,selected:!0,value:null})),T("calcite-panel",{key:"save-layer-panel"},T("div",{class:L.paddingMedium},T("calcite-label",null,this.messages.laverName,T("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),T("calcite-label",null,this.messages.saveInFolder,T("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),T("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),T("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return T("calcite-panel",{class:L.marginInlineMedium,key:"save-layer-processing"},T("calcite-loader",{class:L.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return T("div",{class:L.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this.viewModel.layer?.stops??this._placeholderStops,s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return T("calcite-list-item",{key:e,value:e},s,o,T("div",{class:L.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return T("div",{class:L.stopContainer,key:L.stopContainer},T("calcite-list",{class:L.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:t})=>{e.reorder(t.dragEl.value,t.newIndex),this._resetStopSequence(),this._solveRoute()}},e.toArray().map((e=>this._renderStop(e)))),e.length>1&&T("calcite-action",{icon:"arrow-up-down",onclick:()=>{e.reverse(),this._resetStopSequence(),this._solveRoute()},scale:"s",text:this.messages.reverseStops}))}_renderTravelModes(){return this.viewModel.travelModes.length?T("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,T("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>T("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return T("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([l()],A.prototype,"_currentFlowItem",void 0),e([l()],A.prototype,"_saveState",void 0),e([l()],A.prototype,"apiKey",null),e([l(m)],A.prototype,"defaultUnit",void 0),e([l()],A.prototype,"goToOverride",null),e([l()],A.prototype,"headingLevel",void 0),e([l()],A.prototype,"icon",null),e([l()],A.prototype,"label",null),e([l({readOnly:!0})],A.prototype,"lastRoute",null),e([l()],A.prototype,"layer",null),e([l()],A.prototype,"maxStops",null),e([l(),x("esri/widgets/Directions/t9n/Directions")],A.prototype,"messages",void 0),e([l(),x("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([l()],A.prototype,"searchProperties",void 0),e([l()],A.prototype,"unit",null),e([l()],A.prototype,"view",null),e([l({type:_})],A.prototype,"viewModel",void 0),e([l({type:w,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=e([c("esri.widgets.Directions")],A);const E=A;export{E 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 a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getServiceInfoForLayer as v,getAllStandardFeatureTemplatesForLayer as y}from"../../editing/templateUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isFeatureLayer as b,isSubtypeSublayer as C,isSubtypeGroupLayer as _,isTable as M}from"../../layers/support/layerUtils.js";import{getServices as A}from"../../undoredo/support/Services.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as S}from"../../views/input/InputManager.js";import I from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as j}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as U}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as P}from"./UpdateRecordWorkflow.js";import L from"./UpdateWorkflowData.js";import V from"./Workflow.js";import{createWorkflowSteps as x,fetchCandidates as O}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as R}from"../Feature/support/featureUtils.js";var T;const H="esri.widgets.Editor.UpdateWorkflow",D=()=>o.getLogger(H);let N=T=class extends V{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!b(a?.sourceLayer)&&!C(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new I,l=new T({data:new L({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");z(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r}=t,{view:s}=t.viewModel,n=await A(s).load(),l=v(n,o.sourceLayer)?.featureService,{utilityNetwork:d}=e.allAssociationInputs[0],c=d?.generateDeleteAssociations([i]),p=d?.gdbVersion??void 0;if(!l||!c)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");await r(l,[c],{gdbVersion:p})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!W(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return E.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||_(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=y(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=M(e.sourceLayer)?P:U,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!R(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void G("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&G("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=q(r,s),l=t.getAttribute(n);l||G("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=q(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!M(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return x(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(O(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),S.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new F({view:t,highlightName:j});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function q(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],N.prototype,"activeEditorItem",null),e([m()],N.prototype,"activeFeatureFormViewModel",null),e([m()],N.prototype,"activeSketchViewModel",null),e([m()],N.prototype,"canDeleteAssociation",null),e([m()],N.prototype,"activeWorkflow",null),e([m()],N.prototype,"updating",null),e([m()],N.prototype,"data",void 0),e([m()],N.prototype,"hasPreviousStep",null),e([m()],N.prototype,"hasUpdatableCandidates",null),e([m()],N.prototype,"nestedWorkflowCount",null),e([m()],N.prototype,"shouldShowAttachments",null),e([m()],N.prototype,"shouldAllowAttachmentEditing",null),e([m()],N.prototype,"hasPendingEdits",null),e([m()],N.prototype,"helpMessage",null),e([m()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],N.prototype,"hasInvalidFormTemplate",null),N=T=e([k(H)],N);const G=(e,t)=>D().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),z=e=>!!e&&/update-/.test(e.type),Q=N;export{Q as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as h,watch as w,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as v}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as C,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import A from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as U}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as x}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as O}from"../Feature/support/featureUtils.js";var R;const T="esri.widgets.Editor.UpdateWorkflow",H=()=>o.getLogger(T);let D=R=class extends L{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new S,l=new R({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");G(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r}=t,{sourceLayer:s}=o,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const{utilityNetwork:c}=e.allAssociationInputs[0],p=c?.generateDeleteAssociations([i]);if(!p)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const u=c?.gdbVersion??void 0;await r(d,[p],{gdbVersion:u})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||C(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=v(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=_(e.sourceLayer)?U:E,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!O(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void q("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&q("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||q("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!_(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(x(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),F.TOOL),u=h((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new A({view:t,highlightName:I});e.addHandles([w((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([w((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],D.prototype,"activeEditorItem",null),e([m()],D.prototype,"activeFeatureFormViewModel",null),e([m()],D.prototype,"activeSketchViewModel",null),e([m()],D.prototype,"canDeleteAssociation",null),e([m()],D.prototype,"activeWorkflow",null),e([m()],D.prototype,"updating",null),e([m()],D.prototype,"data",void 0),e([m()],D.prototype,"hasPreviousStep",null),e([m()],D.prototype,"hasUpdatableCandidates",null),e([m()],D.prototype,"nestedWorkflowCount",null),e([m()],D.prototype,"shouldShowAttachments",null),e([m()],D.prototype,"shouldAllowAttachmentEditing",null),e([m()],D.prototype,"hasPendingEdits",null),e([m()],D.prototype,"helpMessage",null),e([m()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],D.prototype,"hasInvalidFormTemplate",null),D=R=e([k(T)],D);const q=(e,t)=>H().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),G=e=>!!e&&/update-/.test(e.type),z=D;export{z 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"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import i from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import{hasEffectiveFeatureExpressionInfo as i}from"../../../support/elevationInfoUtils.js";import l from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as a}from"../../FeatureForm/featureFormUtils.js";let p=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new l({layer:this.layer,layerInfo:this.layerInfo,layerView:this.layerView})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return a(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){if(this.disabled)return!1;if("3d"===this.layerView?.view?.type&&i(this.layer.elevationInfo))return!1;const{enabled:e,geometry:t}=this.capabilities.create;return this.isTable?e:e&&t}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],p.prototype,"_suspended",null),e([r()],p.prototype,"capabilities",null),e([r()],p.prototype,"disabled",void 0),e([r()],p.prototype,"editable",null),e([r()],p.prototype,"formTemplate",null),e([r()],p.prototype,"hasInvalidFormTemplate",null),e([r()],p.prototype,"isTable",null),e([r()],p.prototype,"layer",void 0),e([r()],p.prototype,"layerInfo",void 0),e([r()],p.prototype,"layerView",void 0),e([r()],p.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],p.prototype,"supportsUpdateWorkflow",null),e([r()],p.prototype,"visible",null),p=e([s("esri.widgets.Editor.support.EditorItem")],p);const n=p;export{n as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{watch as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{createTask as s}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as r,initial as a,when as l}from"../../../core/reactiveUtils.js";import{throttle as p}from"../../../core/throttle.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 m}from"../../../core/accessorSupport/decorators/subclass.js";import h from"../../../geometry/Point.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import u from"../../../popup/content/FieldsContent.js";import d from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import f from"../../../popup/content/TextContent.js";import"../../../popup/content/UtilityNetworkAssociationsContent.js";import v from"../../../popup/ElementExpressionInfo.js";import _ from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import w from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcade as T,compileExpression as j}from"../support/arcadeFeatureUtils.js";const k=1;let g=class extends o{constructor(t){super(t),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new y:"media"===t?new w:"text"===t?new _:null;this._set("contentElementViewModel",e)},this._compileThrottled=p(this._startCompile,(()=>this.notifyChange("state")),k,this),this._evaluateThrottled=p(this._startEvaluate,(()=>this.notifyChange("state")),k,this),this.addHandles([r((()=>[this.expressionInfo,this.graphic]),(()=>this._compileThrottled()),a),r((()=>[this.contentElement]),(()=>this._createVM()),a),l((()=>{if(!this._compileTask?.finished)return null;const t=this._compileTask.value,e=t?.dependencies;return[t,this.spatialReference,this.map,this.view,e?.has("view-scale")?this.view?.scale:null,e?.has("view-time-extent")?this.view?.timeExtent?.start:null,e?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([t])=>this._evaluateThrottled(t)))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{contentElement:t,contentElementViewModel:e}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?"loading":t||e?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=s((async t=>{const{expressionInfo:e,graphic:o}=this;if(!e||!o)return null;const s=await T();n(t);const i=await j({expressionInfo:e,arcade:s,graphic:o});return n(t),i}))}_startEvaluate(t){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=s((async e=>{const{graphic:o}=this;if(!t||!o)return null;const{interceptor:s,spatialReference:i,map:r,location:a,view:l}=this,p=await t.evaluate({graphic:o,interceptor:s,location:a,map:r,options:{signal:e},spatialReference:i,view:l});n(e);const c=p;if(!c||"esri.arcade.Dictionary"!==c.declaredClass)return null;const m=await c.castAsJsonAsync(e);n(e);const h=m?.type,v="media"===h?d.fromJSON(m):"text"===h?f.fromJSON(m):"fields"===h?u.fromJSON(m):null;return"media"===v.type&&!v.mediaInfos||"fields"===v.type&&!v.fieldInfos||"text"===v.type&&!v.text?null:v}))}};t([c()],g.prototype,"_compileTask",void 0),t([c()],g.prototype,"_evaluateTask",void 0),t([c({type:v})],g.prototype,"expressionInfo",void 0),t([c({type:e})],g.prototype,"graphic",void 0),t([c({readOnly:!0})],g.prototype,"contentElement",null),t([c({readOnly:!0})],g.prototype,"contentElementViewModel",void 0),t([c()],g.prototype,"interceptor",void 0),t([c({type:h})],g.prototype,"location",void 0),t([c()],g.prototype,"spatialReference",null),t([c({readOnly:!0})],g.prototype,"state",null),t([c()],g.prototype,"map",null),t([c()],g.prototype,"view",void 0),g=t([m("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],g);const E=g;export{E 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{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import o from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Identifiable.js";import a from"../../core/Logger.js";import{isAbortError as l,eachAlways as c}from"../../core/promiseUtils.js";import{watch as p,on as d,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{throttle as f}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import b from"../../geometry/Point.js";import g from"../../geometry/SpatialReference.js";import A from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as w}from"../../support/popupUtils.js";import{system as I}from"../../time/timeZoneUtils.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import v from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import C from"./FeatureFields/FeatureFieldsViewModel.js";import x from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{createCompiledExpressions as T}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as E,getAllFieldInfos as j,getSourceLayer as P,querySourceLayer as R,isRelatableFeatureSupportedLayer as L,isAssociatedFeatureSupportedLayer as O,substituteFieldsInLinksAndAttributes as Z,isExpressionField as k,isRelatedField as N,formatEditInfo as U,graphicCallback as B,queryUpdatedFeature as S,formatAttributes as H,preLayerQueryCallback as D,preRequestCallback as G}from"./support/featureUtils.js";import{queryLayerInfos as q,queryRelatedFeatures as Q,setRelatedFeatures as z,getRelatedFieldInfo as J,createRelatedInfo as K,updateRelatedInfo as W}from"./support/relatedFeatureUtils.js";import X from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var Y;const $=1,ee="content-view-models",te="relationship-view-models",ie="association-view-models",oe={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let re=Y=class extends(n.IdentifiableMixin(o)){constructor(e){super(e),this._error=null,this._featureAbortController=null,this._associationVMAbortController=null,this._graphicChangedThrottled=f(this._graphicChanged,$,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...oe},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this.addHandles(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),h))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(j(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return P(this.graphic)}castAbilities(e){return{...oe,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._featureAbortController=new AbortController,this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??I}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){return!(!this._featureAbortController&&!this._associationVMAbortController)}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof x&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const o=i?.objectIdField;if(!o||!e||!i)return;const r=e?.attributes?.[o];if(null==r)return;const s=[r];if(!e.geometry){const o=await R({layer:i,graphic:e,outFields:[],objectIds:s,returnGeometry:!0,spatialReference:t}),r=o?.geometry;r&&(e.geometry=r)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(i){l(i)||(this._error=i,a.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(r):"string"==typeof e?this._compileText(new A({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(te),this.removeHandles(ee),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),o=t?.getObjectId();return null!=i&&null!=o&&i===o}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:o,spatialReference:r,timeZone:s}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new Y({abilities:{relationshipContent:!1},map:i,view:o,spatialReference:r,timeZone:s,graphic:t}))})),e.forEach((i=>{const o=t?.find((e=>this._matchesFeature(i,e)));o||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:o,contentElementViewModel:r}=e,s=o?.type;r&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createFieldsVMParams(o,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createMediaVMParams(o,t))),"text"===s&&r.set(this._createTextVMParams(o)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:o,relationshipId:r,title:s,description:n}=e,{_sourceLayer:a,graphic:l,map:c}=this;if(!L(a))return;const p=new V({displayCount:i,graphic:l,orderByFields:o,relationshipId:r,layer:a,map:c,...this._compileTitleAndDesc({title:s,description:n})});return this.contentViewModels[t]=p,this.addHandles(d((()=>p.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(p))),te),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,o=t?.association.globalId;return null!=i&&null!=o&&i===o}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:o,spatialReference:r,timeZone:n}=this;e.forEach(((i,o)=>{const r=t.get(o);r?i.forEach((t=>{r.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(o))})):(i.removeAll(),e.delete(o))})),t.forEach(((t,a)=>{const l=e.get(a)||new s;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new Y({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:o,spatialReference:r,timeZone:n,graphic:e.feature}),terminalName:e.terminalName})})),e.set(a,l)}));const a=new AbortController;this._associationVMAbortController=a,await this._sortListObjectsByTitle(e,{signal:a.signal}),this._associationVMAbortController===a&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>u((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=w(e.featureViewModel),o=w(t.featureViewModel);return i.localeCompare(o,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:o,description:r,associationTypes:s}=e,{_sourceLayer:n,graphic:a,map:l}=this;if(!O(n))return;const c=new X({graphic:a,displayCount:i,associationTypes:s,layer:n,map:l,...this._compileTitleAndDesc({title:o,description:r})});return this.contentViewModels[t]=c,this.addHandles([p((()=>c.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(c.associationViewModels,c.associationFeatures,c.map)))],ie),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:o,map:r,spatialReference:s,view:n,location:a}=this,l=new F({expressionInfo:i,graphic:o,interceptor:Y.interceptor,map:r,spatialReference:s,view:n,location:a});return this.contentViewModels[t]=l,this.addHandles(p((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),h),ee),e}_compileAttachments(e,t){const{graphic:i}=this,{description:o,title:r,orderByFields:s}=e;return this.contentViewModels[t]=new M({graphic:i,orderByFields:s,...this._compileTitleAndDesc({title:r,description:o})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:o,destroyer:r}=e;return this.contentViewModels[t]=new v({graphic:i,creator:o,destroyer:r}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:o,graphic:r,formattedAttributes:s}=this,n=r?.attributes,a=this._expressionAttributes,l=s.global;return{title:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:e}),description:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,o=this.formattedAttributes,r={...o?.global,...o?.content[t]},s=e?.fieldInfos||i?.fieldInfos,n=s?.filter((({fieldName:e})=>!!e&&(k(e)||N(e)||r.hasOwnProperty(e)))),a=i?.expressionInfos,{description:l,title:c}=e;return{attributes:r,expressionInfos:a,fieldInfos:n,...this._compileTitleAndDesc({title:c,description:l})}}_compileFields(e,t){const i=e.clone(),o=new C(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=o,i.fieldInfos=o.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:o,_fieldInfoMap:r,_effectivePopupTemplate:s,relatedInfos:n,_sourceLayer:a,_expressionAttributes:l}=this,c=this.formattedAttributes,p=o?.attributes??{},{description:d,mediaInfos:u,title:h}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:p,isAggregate:o?.isAggregate,layer:a,fieldInfoMap:r,formattedAttributes:{...c?.global,...c?.content[t]},expressionAttributes:l,mediaInfos:u,popupTemplate:s,relatedInfos:n,...this._compileTitleAndDesc({title:h,description:d})}}_compileMedia(e,t){const i=e.clone(),o=new x(this._createMediaVMParams(e,t));return i.mediaInfos=o.formattedMediaInfos.slice(),this.contentViewModels[t]=o,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:o,_expressionAttributes:r}=this;if(e&&e.text){const s=t?.attributes??{},n=this.formattedAttributes?.global??{};e.text=Z({attributes:s,fieldInfoMap:i,globalAttributes:n,expressionAttributes:r,layer:o,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new v(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:o}=this;if(!e)return;const{lastEditInfoEnabled:r}=e,s=t?.editFieldsInfo;return r&&s?U(s,i?.attributes,o,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:o,_expressionAttributes:r}=this,s=o?.attributes??{},n=this.formattedAttributes?.global??{};return Z({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:r,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"content",value:e?.content,event:{graphic:t}}):null}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:i,graphic:o,_effectivePopupTemplate:r}=this,s=this.map,n=this.view,a=this.spatialReference,l=this.location;if(t!==this._featureAbortController||!o)return;await S({graphic:o,popupTemplate:r,layer:i,spatialReference:a},e);const{content:{value:p},title:{value:d}}=await c({content:this._getContent(),title:this._getTitle()}),{expressionAttributes:{value:u}}=await c({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:T({expressionInfos:r?.expressionInfos,spatialReference:a,graphic:o,map:s,interceptor:Y.interceptor,view:n,options:e,location:l})});t===this._featureAbortController&&o&&(this._expressionAttributes=u,this._graphicExpressionAttributes={...o.attributes,...u},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(d)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:o,graphic:r,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l,timeZone:c}=this;i.content[t]=H({fieldInfos:o?.fieldInfos,graphic:r,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:o,relatedInfos:r,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a,timeZone:l}=this;i.content[t]=H({fieldInfos:e.fieldInfos,graphic:o,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:r,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:s,_graphicExpressionAttributes:n,timeZone:a}=this,l=t?.fieldInfos,c={global:H({fieldInfos:l,graphic:i,attributes:n,layer:r,fieldInfoMap:s,relatedInfos:o,timeZone:a}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c})})),c}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,j(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:o,_sourceLayer:r}=this;o.clear();const s=null!=r?.associatedLayer?await(r?.associatedLayer.load(i)):r;if(!s||!e)return;const n=t.filter((e=>!!e.fieldName&&N(e.fieldName)));if(!n?.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const a=await q({relatedInfos:o,layer:s},i);Object.keys(a).forEach((e=>{const t=o.get(e.toString()),i=a[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await Q({graphic:e,relatedInfos:o,layer:s},i);Object.keys(l).forEach((e=>{z(l[e]?.value,o.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,o=J(e.fieldName||"");if(!o)return;const{layerId:r,fieldName:s}=o;if(!r)return;const n=i.get(r.toString())||K(r,t);n&&(W({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(r,n))}};re.interceptor=new i(D,G),e([m()],re.prototype,"_error",void 0),e([m()],re.prototype,"_featureAbortController",void 0),e([m()],re.prototype,"_associationVMAbortController",void 0),e([m({readOnly:!0})],re.prototype,"_effectivePopupTemplate",null),e([m({readOnly:!0})],re.prototype,"_fieldInfoMap",null),e([m({readOnly:!0})],re.prototype,"_sourceLayer",null),e([m()],re.prototype,"abilities",void 0),e([_("abilities")],re.prototype,"castAbilities",null),e([m({readOnly:!0})],re.prototype,"content",void 0),e([m({readOnly:!0})],re.prototype,"contentViewModels",void 0),e([m()],re.prototype,"description",void 0),e([m({type:Boolean})],re.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],re.prototype,"isTable",null),e([m({readOnly:!0})],re.prototype,"state",null),e([m({readOnly:!0})],re.prototype,"formattedAttributes",void 0),e([m({type:t,value:null})],re.prototype,"graphic",null),e([m({readOnly:!0})],re.prototype,"lastEditInfo",void 0),e([m({type:b})],re.prototype,"location",void 0),e([m({readOnly:!0})],re.prototype,"relatedInfos",void 0),e([m({type:g})],re.prototype,"spatialReference",null),e([m()],re.prototype,"timeZone",null),e([m({readOnly:!0})],re.prototype,"title",void 0),e([m()],re.prototype,"map",null),e([m({readOnly:!0})],re.prototype,"waitingForContent",null),e([m()],re.prototype,"view",void 0),re=Y=e([y("esri.widgets.Feature.FeatureViewModel")],re);const se=re;export{se as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import n from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,on as m,whenOnce as _,initial as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{cast as w}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import M from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as x}from"../../support/popupUtils.js";import{system as T}from"../../time/timeZoneUtils.js";import C from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import E from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import V from"./FeatureFields/FeatureFieldsViewModel.js";import j from"./FeatureMedia/FeatureMediaViewModel.js";import k from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as P,formatArcadeValue as R}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as L,getAllFieldInfos as O,getSourceLayer as U,querySourceLayer as Z,isRelatableFeatureSupportedLayer as N,isAssociatedFeatureSupportedLayer as B,substituteFieldsInLinksAndAttributes as S,isExpressionField as H,isRelatedField as D,formatEditInfo as G,graphicCallback as q,formatAttributes as z,preLayerQueryCallback as Q,preRequestCallback as J,queryUpdatedFeature as K}from"./support/featureUtils.js";import{queryLayerInfos as W,queryRelatedFeatures as X,setRelatedFeatures as Y,getRelatedFieldInfo as $,createRelatedInfo as ee,updateRelatedInfo as te}from"./support/relatedFeatureUtils.js";import ie from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var se;const oe=1,re="content-view-models",ae="relationship-view-models",ne="association-view-models",le={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let pe=se=class extends(n.IdentifiableMixin(s)){constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...le},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,(()=>this.notifyChange("waitingForContent")),oe,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,(()=>this.notifyChange("waitingForContent")),oe,this),this.addHandles([u((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),y),f((()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([e])=>this._evaluateExpressionAttributesThrottled(e)))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return L(O(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return U(this.graphic)}castAbilities(e){return{...le,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof j&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await Z({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r((async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await K({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),P(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}}))}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(o):"string"==typeof e?this._compileText(new M({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(ae),this.removeHandles(re),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new se({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))})),e.forEach((i=>{const s=t?.find((e=>this._matchesFeature(i,e)));s||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!N(n))return;const c=new k({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(m((()=>c.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(c))),ae),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach(((i,s)=>{const o=t.get(s);o?i.forEach((t=>{o.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(s))})):(i.removeAll(),e.delete(s))})),t.forEach(((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new se({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:e.feature}),terminalName:e.terminalName})})),e.set(n,l)}));const n=new AbortController;this._associationVMAbortController=n,await this._sortListObjectsByTitle(e,{signal:n.signal}),this._associationVMAbortController===n&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>_((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=x(e.featureViewModel),s=x(t.featureViewModel);return i.localeCompare(s,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!B(a))return;const p=new ie({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u((()=>p.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map)))],ne),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:se.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),y),re),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new C({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new E({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter((({fieldName:e})=>!!e&&(H(e)||D(e)||o.hasOwnProperty(e)))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new V(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new j(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=S({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new E(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?G(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return S({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r((async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:se.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then((e=>[t,R(e)])).catch((()=>[t,void 0]))):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}}))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=z({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=z({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:z({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})})),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,O(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter((e=>!!e.fieldName&&D(e.fieldName)));if(!a?.length)return;t.forEach((e=>this._configureRelatedInfo(e,r)));const n=await W({relatedInfos:s,layer:r},i);Object.keys(n).forEach((e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await X({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach((e=>{Y(l[e]?.value,s.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=$(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||ee(o,t);a&&(te({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};pe.interceptor=new i(Q,J),e([b()],pe.prototype,"_error",void 0),e([b()],pe.prototype,"_graphicChangedTask",void 0),e([b()],pe.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],pe.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],pe.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],pe.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],pe.prototype,"_sourceLayer",null),e([b()],pe.prototype,"abilities",void 0),e([w("abilities")],pe.prototype,"castAbilities",null),e([b({readOnly:!0})],pe.prototype,"content",void 0),e([b({readOnly:!0})],pe.prototype,"contentViewModels",void 0),e([b()],pe.prototype,"description",void 0),e([b({type:Boolean})],pe.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],pe.prototype,"isTable",null),e([b({readOnly:!0})],pe.prototype,"state",null),e([b({readOnly:!0})],pe.prototype,"formattedAttributes",void 0),e([b({type:t,value:null})],pe.prototype,"graphic",null),e([b({readOnly:!0})],pe.prototype,"lastEditInfo",void 0),e([b({type:A})],pe.prototype,"location",void 0),e([b({readOnly:!0})],pe.prototype,"relatedInfos",void 0),e([b({type:I})],pe.prototype,"spatialReference",null),e([b()],pe.prototype,"timeZone",null),e([b({readOnly:!0})],pe.prototype,"title",void 0),e([b()],pe.prototype,"map",null),e([b({readOnly:!0})],pe.prototype,"waitingForContent",null),e([b()],pe.prototype,"view",void 0),pe=se=e([v("esri.widgets.Feature.FeatureViewModel")],pe);const ce=pe;export{ce 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{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import
|
|
5
|
+
import{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as n}from"./featureUtils.js";import{globalCss as s}from"../../support/globalCss.js";const o="esri.widgets.Feature.support.arcadeFeatureUtils",i=()=>r.getLogger(o);function c(e){return"string"==typeof e?a(n(e)):Array.isArray(e)?p(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function p(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?a(n(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?a(n(t)):t}</td></tr>`})).join("");return`<table class="${s.table}">${r}</table>`}async function l(){const[e,r]=await Promise.all([import("../../../arcade.js"),import("../../../arcade/arcade.js")]);return{executor:e,syntaxUtils:r}}function d(e){return"createQuery"in e&&"queryFeatures"in e}async function y({graphic:e,view:r,options:t}){const{isAggregate:a,layer:n}=e;if(!a||!n||"2d"!==r?.type)return[];const s=await r.whenLayerView(n);if(!d(s))return[];const o=s.createQuery(),i=e.getObjectId();o.aggregateIds=null!=i?[i]:[];const{features:c}=await s.queryFeatures(o,t);return c}function f({layer:e,aggregatedFeatures:r,interceptor:a}){const{fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c}=e;return new t({fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c,interceptor:a,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}function g(e){const r="esri.views.3d.layers.VoxelGraphic"===e.declaredClass;return e.isAggregate?"feature-reduction-popup":r?"popup-voxel":"popup"}function w(e){return{scale:e?.scale,timeProperties:{currentStart:e?.timeExtent?.start,currentEnd:e?.timeExtent?.end,startIncluded:!0,endIncluded:!0}}}function m(e){return{$voxel:e}}async function x(e,r,t,a,n){let s=null;if(n.has("$aggregatedfeatures")){const n=await y({graphic:e,view:r,options:t}),o=e.sourceLayer||e.layer;s=f({layer:o,aggregatedFeatures:n,interceptor:a})}return{vars:{$feature:e,$aggregatedFeatures:s,$view:w(r)},[Symbol.dispose]:()=>s?.[Symbol.dispose]()}}function v(r,t,a,n){const s=(r.sourceLayer||r.layer)??void 0;return{$feature:r,$layer:null!=s&&e(s)?s:"scene"===s?.type&&null!=s.associatedLayer?s.associatedLayer:void 0,$map:t,$datastore:s?.url,$userInput:a,$graph:"knowledge-graph-sublayer"===s?.type?s?.parentCompositeLayer?.knowledgeGraph:void 0,$view:w(n)}}async function h(e,{graphic:r,map:t,location:a,view:n,options:s,interceptor:o,arcadeExecutor:i}){switch(e){case"popup":return{vars:v(r,t,a,n),[Symbol.dispose](){}};case"feature-reduction-popup":{const e=new Set(i.variablesUsed);return await x(r,n,s,o,e)}case"popup-voxel":return{vars:m(r),[Symbol.dispose](){}};default:throw new Error(`Unexpected profile name ${e}`)}}async function $({expressionInfo:e,arcade:{executor:r,syntaxUtils:t},graphic:a}){const n=e?.expression;if(!n)return null;const s=g(a),o=r.createArcadeProfile(s);let c;try{c=await r.createArcadeExecutor(n,o)}catch(u){return i().error("arcade-executor-error",{error:u,expressionInfo:e}),null}const p=new Set;return c.variablesUsed.includes("$view")&&(t.scriptUsesViewProperties(c.syntaxTree,["scale"])&&p.add("view-scale"),t.scriptUsesViewProperties(c.syntaxTree,["timeProperties"])&&p.add("view-time-extent")),{dependencies:p,async evaluate({graphic:r,interceptor:t,location:a,map:n,options:o,spatialReference:p,view:l}){const d=await h(s,{graphic:r,map:n,location:a,view:l,options:o,interceptor:t,arcadeExecutor:c}),y={abortSignal:o?.signal??void 0,interceptor:t??void 0,rawOutput:!0,spatialReference:p??void 0,timeZone:l?.timeZone,console(...e){i().info(...e)}};try{return await c.executeAsync(d.vars,y)}catch(u){return void i().error("arcade-execution-error",{error:u,graphic:r,expressionInfo:e})}finally{d[Symbol.dispose]()}}}}async function b(e,r){if(!e?.length)return{dependencies:new Set,expressions:new Map};const t=await l(),a=new Set,n=new Map;for(const s of e){const e=await $({expressionInfo:s,arcade:t,graphic:r});n.set(`expression/${s.name}`,e),e?.dependencies.forEach((e=>a.add(e)))}return{dependencies:a,expressions:n}}export{$ as compileExpression,b as compileExpressionInfos,c as formatArcadeValue,l as loadArcade};
|
|
@@ -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{createTask as t}from"../../../../core/asyncUtils.js";import a from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{createTask as t}from"../../../../core/asyncUtils.js";import a from"../../../../core/Promise.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{load as o}from"../../../../geometry/projection.js";import{convertSphereVertexToPixelLocation as n}from"../../../../layers/orientedImagery/transformations/utils.js";import{SketchHandlerMixin as c}from"../../mixins/SketchHandlerMixin.js";let l=[],u=[],h=0,m=class extends(c(a)){constructor(e){super(e),this.type="measurement",this.measurementArray=[],this.pixelMeasurement=0,this.pixelAreaMeasurement=0,this.polygonVertices=[],this._calculationTask=null,this._distanceCalculation=0,this._areaCalculation=null}initialize(){this.addResolvingPromise(o())}async handleCreate(e){const t=e.toolEventInfo;switch(e.tool){case"polyline":this.handlePolylineEvents(e,t);break;case"polygon":this.handlePolygonEvents(e,t)}}handleDelete(e){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}handleDestroy(){this.resetDistanceMeasurements(),this.resetAreaMeasurements()}cursorUpdatePolylineHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;if("default"===t)this.measurementArray.push(e.coordinates);else{const t={x:e.coordinates[0],y:e.coordinates[1],z:e.coordinates[2]},s=n(t,a.imageSize[0],a.imageSize[1]);this.measurementArray.push([s.x,s.y])}const s=u.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=s}async cursorUpdatePolygonHandler(e){const{mode:t,activeViewer:a}=this.viewModel;if("none"===t||!a?.imageSize)return;const s=e.coordinates;if(l=[...this.polygonVertices],"default"===t)l.push(s);else{const e={x:s[0],y:s[1],z:s[2]},t=n(e,a?.imageSize[0],a?.imageSize[1]);l.push([t.x,t.y])}if(l.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;const i=l[0];l=l.filter(((e,t)=>0===t||t===l.length-1||JSON.stringify(e)!==JSON.stringify(i)));const r=await this._getAreaFromTask(l);r?.area&&r?.perimeter&&(h=r.area)}async handlePolylineEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetDistanceMeasurements(),this.viewModel.distanceMeasurementResult=0,this.viewModel.distanceAccuracyArray=[],void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetDistanceMeasurements();switch(t?.type){case"cursor-update":this.cursorUpdatePolylineHandler(t);break;case"vertex-add":if(this.measurementArray.length&&a){const e=await this._getAccuracyFromTask();e&&this.viewModel.distanceAccuracyArray.push(e)}this.vertexUpdatePolylineHandler()}const s=await this._getDistanceFromTask();this.pixelMeasurement=s??this.pixelMeasurement}async handlePolygonEvents(e,t){const a=!this.viewModel.accuracyParametersMissing;if("cancel"===e.state)return this.resetAreaMeasurements(),this.viewModel.areaMeasurementResult=0,this.viewModel.areaMeasurementAccuracy=0,void(this.viewModel.displayNewMeasurementButton=!0);if("complete"===e.state&&e.graphic)return this.viewModel.activeViewer?.addGraphic(e.graphic),this.viewModel.measurementGraphic=e.graphic,void this.resetAreaMeasurements();switch(t?.type){case"vertex-add":await this.vertexAddPolygonHandler(t,a);break;case"cursor-update":await this.cursorUpdatePolygonHandler(t)}this.viewModel.areaMeasurementResult=h>0?h:this.pixelAreaMeasurement}async vertexAddPolygonHandler(e,t){const{mode:a,activeViewer:s}=this.viewModel,i=e.added,r=i[i.length-1];if(!Array.isArray(r)||"none"===a||!s?.imageSize)return;if("default"===a)this.polygonVertices.push(r);else{const e={x:r[0],y:r[1],z:r[2]},t=n(e,s?.imageSize[0],s?.imageSize[1]);this.polygonVertices.push([t.x,t.y])}if(this.polygonVertices.length<3||!this.viewModel.currentBestFeature||!this.viewModel.activeViewer?.imageSize)return;if(t){const e=await this._getAreaAccuracyFromTask(this.polygonVertices);this.viewModel.areaMeasurementAccuracy=e&&e>this.viewModel.areaMeasurementAccuracy?e:this.viewModel.areaMeasurementAccuracy}const o=this.polygonVertices[0];this.polygonVertices=this.polygonVertices.filter(((e,t)=>0===t||t===this.polygonVertices.length-1||JSON.stringify(e)!==JSON.stringify(o)));const c=await this._getAreaFromTask(this.polygonVertices);if(!c?.area||!c?.perimeter)return;const{area:l}=c;this.pixelAreaMeasurement=l}vertexUpdatePolylineHandler(){this.measurementArray=this.measurementArray.slice(-1);const e=u.reduce(((e,t)=>e+t),0)+this.pixelMeasurement;this.viewModel.distanceMeasurementResult=e,this.pixelMeasurement>0&&u.push(this.pixelMeasurement)}resetDistanceMeasurements(){this.measurementArray=[],this.pixelMeasurement=0,u=[]}resetAreaMeasurements(){this.polygonVertices=[],this.pixelAreaMeasurement=0,h=0}async _getAreaFromTask(e){const{mode:a}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._areaCalculation=null;const i=await this.viewModel.calculateAreaMeasurement(e,a,t);s(t),this._areaCalculation=i})),await this._calculationTask.promise,this._areaCalculation}async _getDistanceFromTask(){const{mode:e}=this.viewModel;return this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a=await this.viewModel.calculateDistanceMeasurement(this.measurementArray,e,t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation}async _getAccuracyFromTask(){const{mode:e}=this.viewModel;return"none"===e?null:(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const a="default"===e?await this.viewModel.calculateAccuracy(this.measurementArray,"distance",t):await this.viewModel.calculateAccuracyPanoramic(this.measurementArray,"distance",t);s(t),this._distanceCalculation=a})),await this._calculationTask.promise,this._distanceCalculation)}async _getAreaAccuracyFromTask(e){const{mode:a}=this.viewModel;return"none"===a?null:(this._calculationTask?.abort(),this._calculationTask=t((async t=>{this._distanceCalculation=0;const i="default"===a?await this.viewModel.calculateAccuracy(e,"area",t):await this.viewModel.calculateAccuracyPanoramic(e,"area",t);s(t),this._distanceCalculation=i})),await this._calculationTask.promise,this._distanceCalculation)}};e([i()],m.prototype,"type",void 0),e([i()],m.prototype,"measurementArray",void 0),e([i()],m.prototype,"pixelMeasurement",void 0),e([i()],m.prototype,"pixelAreaMeasurement",void 0),e([i()],m.prototype,"polygonVertices",void 0),m=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.MeasurementAdapter")],m);const d=m;export{d 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
|
|
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};
|