@arcgis/core 4.23.0-next.20220321 → 4.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{678c94b331fde96e6998.js → 52c972e98d60a0c62a6b.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{e8e775758b79c5a084c8.js → 86ec93705546377103b0.js} +1 -1
  4. package/assets/esri/core/workers/chunks/9f458f10dc65b185f66e.js +1 -0
  5. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +2 -2
  6. package/assets/esri/themes/base/widgets/_LayerList.scss +2 -2
  7. package/assets/esri/themes/dark/main.css +1 -1
  8. package/assets/esri/themes/dark-blue/main.css +1 -1
  9. package/assets/esri/themes/dark-green/main.css +1 -1
  10. package/assets/esri/themes/dark-purple/main.css +1 -1
  11. package/assets/esri/themes/dark-red/main.css +1 -1
  12. package/assets/esri/themes/light/main.css +1 -1
  13. package/assets/esri/themes/light/view.css +1 -1
  14. package/assets/esri/themes/light-blue/main.css +1 -1
  15. package/assets/esri/themes/light-green/main.css +1 -1
  16. package/assets/esri/themes/light-purple/main.css +1 -1
  17. package/assets/esri/themes/light-red/main.css +1 -1
  18. package/config.js +1 -1
  19. package/core/reactiveUtils.js +1 -1
  20. package/interfaces.d.ts +4 -4
  21. package/layers/support/FeatureReductionCluster.js +1 -1
  22. package/package.json +1 -1
  23. package/support/basemapUtils.js +1 -1
  24. package/support/revision.js +1 -1
  25. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  26. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  27. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  28. package/views/2d/layers/LayerView2D.js +1 -1
  29. package/views/MapView.js +1 -1
  30. package/views/layers/GroupLayerView.js +1 -1
  31. package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
  32. package/widgets/Feature/FeatureMedia.js +1 -1
  33. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  34. package/widgets/FeatureForm/InputField.js +1 -1
  35. package/assets/esri/core/workers/chunks/70b0b6d9559960307059.js +0 -1
package/views/MapView.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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import s from"../core/Collection.js";import n from"../core/CollectionFlattener.js";import r from"../core/Error.js";import a from"../core/has.js";import{isIterable as o}from"../core/iteratorUtils.js";import l from"../core/Logger.js";import{isSome as p,unwrap as h,isNone as c}from"../core/maybe.js";import{throwIfAborted as d}from"../core/promiseUtils.js";import{watch as u,whenOnce as m,sync as g,syncAndInitial as f}from"../core/reactiveUtils.js";import{createScreenPoint as w}from"../core/screenUtils.js";import y from"../core/Warning.js";import{initialize as v}from"../core/workers/workers.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as V}from"../core/accessorSupport/decorators/subclass.js";import S from"../geometry/Extent.js";import j from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as R,project as b,isLoaded as x}from"../geometry/projection.js";import{equals as M}from"../geometry/support/spatialReferenceUtils.js";import O from"../layers/support/TileInfo.js";import{BreakpointsOwner as k}from"./BreakpointsOwner.js";import{DOMContainer as z}from"./DOMContainer.js";import{PopupView as L}from"./PopupView.js";import P from"./View.js";import C from"./ViewAnimation.js";import E from"./2d/AnimationManager.js";import G from"./2d/FrameTask.js";import{layerView2DImporter as N}from"./2d/layerViewModuleImportUtils.js";import D from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import U from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as A,setExtent as I,rotateTo as F,scaleTo as W,copy as B,create as H,extentToScale as $,resize as J,angleBetween as Q}from"./2d/viewpointUtils.js";import Z from"./2d/input/MapViewInputManager.js";import K from"./2d/layers/features/support/TileStore.js";import X from"./2d/support/HighlightOptions.js";import{Timeline as Y}from"./2d/support/Timeline.js";import ee from"./support/createScreenshotPlan.js";import{getMaximumResolutionScale as te,getFormatAndQuality as ie}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as se,createScreenPointFromSupportedEvent as ne}from"./support/screenUtils.js";import{check as re}from"./support/WebGLRequirements.js";import ae from"./ui/2d/DefaultUI2D.js";import oe from"../webmap/background/ColorBackground.js";const le=l.getLogger("esri.views.MapView");let pe,he,ce,de,ue,me;async function ge(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:n,Stage:r}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);he=e,ce=t,de=i,ue=s,me=n,pe=r}const fe=160;function we(e){return e&&"esri.Viewpoint"===e.declaredClass}let ye=class extends(k(z(L(P)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new n({getCollections:()=>{var e,t;return[null==(e=this.basemapView)?void 0:e.baseLayerViews,this.layerViews,null==(t=this.basemapView)?void 0:t.referenceLayerViews]},getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!1,this.supportsGround=!1,this._stationaryTimer=null,this.frameTask=new G(this),this._pePromise=null,this.floors=new s,this.highlightOptions=new X,this.inputManager=new Z({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new Y,this.type="2d",this.ui=new ae,this.constraints=new D,this.padding={top:0,right:0,bottom:0,left:0},this.handles.add([u((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(fe)}),g),this.on("resize",(e=>this._resizeHandler(e))),u((()=>{var e;return null==(e=this.animationManager)?void 0:e.animation}),(e=>{this.animation=e}))]),v()}destroy(){this._set("preconditionsReady",!1),this._gotoTask=this.frameTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new K(this.featuresTilingScheme)}get initialExtentRequired(){var e;const{scale:t,constraints:i,center:s,viewpoint:n,extent:r}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&null!=(e=this.map.initialViewProperties)&&e.viewpoint)&&(!r&&(null!=i&&i.effectiveLODs||(a=-1),(!s||0===t&&-1===a)&&(!n||!p(n.targetGeometry)||"extent"!==n.targetGeometry.type&&!n.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!x()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=h(e.targetGeometry);return!!R(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask.requestFrame()),this.frameTask.animationInProgress=!1};e.when(i,i)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new j({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void le.error(new r("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;A(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(u((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),g),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void le.error(new r("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void le.error(new r("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;I(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;F(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;W(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){return!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)))}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new r("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):c(e.targetGeometry)&&(s=new r("mapview:invalid-viewpoint","geometry not defined"))}catch(a){s=new r("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:a})}if(s)return void le.error(s);this._scaleBeforeChangingSpatialReference=null;const n=new i({targetGeometry:new j,scale:0,rotation:0});B(n,t),this.constraints.constrain(n,this.state.paddedViewState.viewpoint),this.state.viewpoint=n,this.frameTask.requestFrame(),this._set("viewpoint",n)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;W(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),m((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=H(e,this);return this.animation.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));le.error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=se(e)?ne(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let s=new Set,n=!1,r=null,a=null;null!=t&&t.include?Se(t.include,Ve(this,(e=>s.add(e)),(e=>{r||(r=new Set),r.add(e)}),(e=>s.add(e)),(()=>n=!0))):(n=!0,s=new Set(this.allLayerViews)),null!=t&&t.exclude&&Se(t.exclude,Ve(this,(e=>s.delete(e)),(e=>{a||(a=new Set),a.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&s.has(e))).reverse(),l=this.toMap(i);let h=(await Promise.all([n?this.graphicsView.hitTest(l):null,...o.map((e=>e.hitTest(l,i)))])).filter(p).flat();return r&&(h=h.filter((e=>r.has(_e(e))))),a&&(h=h.filter((e=>!a.has(_e(e))))),{screenPoint:i,results:h.map((e=>({mapPoint:l,graphic:e})))}}takeScreenshot(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,te(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:s,quality:n}=ie(e.format,e.quality),r=ee(e,t,this.size,this.padding,s,n,i,e.rotation);return this._stage.takeScreenshot(r)}toMap(e){if(!this.ready)return null;const t=se(e)?ne(this,e):e,i=[0,0],[s,n]=this.state.toMap(i,[t.x,t.y]),r=this.spatialReference;return new j({x:s,y:n,spatialReference:r})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),w(i[0],i[1])}on(e,t,i,s){const n=this.inputManager&&this.viewEvents.on(e,t,i,s);return n||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||null}hasLayerViewModule(e){return N.hasLayerViewModule(e)}importLayerView(e){return N.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(le.error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=re(this.type);return a("safari")&&a("safari")<9&&(e=new r("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),p(e)?(le.warn("#validate()",e.message),Promise.reject(e)):ge()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new C),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,n=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(this.animation=null,t.done||(t.stop(),this.frameTask.animationInProgress=!1)),e})),r=new Promise((e=>e(n)));return t.when().catch((()=>{s()&&r.cancel&&r.cancel()})),r}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,n=e.then((e=>{if(d(t),i!==this._gotoTask)throw new r("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,n)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<fe&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){var e,t,s,n;const{constraints:r,initialExtent:a,map:o}=this;if(!r)return null;const l=o&&"initialViewProperties"in o&&o.initialViewProperties,c={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};r.effectiveLODs?-1!==c.zoom&&(c.scale=r.zoomToScale(c.zoom)):c.zoom=-1;let d=null,u=null,m=0;const g=c.viewpoint&&c.viewpoint.rotation,f=c.viewpoint&&c.viewpoint.targetGeometry;p(f)&&("extent"===f.type?d=f:"point"===f.type&&(u=f,m=c.viewpoint.scale));const w=c.extent||d||(null==(e=h(null==l||null==(t=l.viewpoint)?void 0:t.targetGeometry))?void 0:e.extent)||a,y=c.center||u||(null==w?void 0:w.center),v=c.scale||m||(null==l||null==(s=l.viewpoint)?void 0:s.scale)||w&&$(w,this.size),_=c.rotation||g||(null==l||null==(n=l.viewpoint)?void 0:n.rotation)||0;return y&&v?new i({targetGeometry:y,scale:v,rotation:_}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation,n=e.then((e=>{if(d(t),i!==this._gotoTask)throw new r("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,n)}_project(e,t){var i;const s=e&&e.targetGeometry||e;if(!t)return e;if(!s)return null;if(t.imageCoordinateSystem||null!=(i=s.spatialReference)&&i.imageCoordinateSystem)return e;if(M(t,s.spatialReference))return e;const n=b(s,t);if(!n)throw new r("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:s,spatialReference:t});return we(e)?(e.targetGeometry=n,e):n}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],J(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,null),this.state.viewpoint=i}_startup(){var e;this.timeline.begin("MapView Startup");const t=this._getDefaultViewpoint(),i=t.targetGeometry;try{this._project(t,this.spatialReference)}catch(p){var s;le.warn(new y("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:i.toJSON(),spatialReference:this.spatialReference,error:p})),t.targetGeometry=(null==(s=this.defaultsFromMap.extent)?void 0:s.center)||new j({x:0,y:0,spatialReference:this.spatialReference})}null==(e=this.constraints)||e.fit(t),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:t})),this.graphics.owner=this;const n=new pe(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=n,this._magnifierView=new me,this._magnifierView.magnifier=this.magnifier;const r=new de({view:this});this._set("labelManager",r);const a=new E({view:this});this._set("animationManager",a);const o=new ue({view:this,animationManager:a});this._set("mapViewNavigation",o),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),n.on("post-render",(()=>this._set("rendering",n.renderRequested))),n.on("will-render",(()=>this._set("rendering",n.renderRequested))),n.on("webgl-error",(e=>this.fatalError=e.error)),u((()=>this.stationary),(e=>n.stationary=e),f),u((()=>this.background),(e=>{n.background=e,this._magnifierView.background=e}),f),u((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),f),u((()=>this.renderingOptions),(e=>n.renderingOptions=e),f),u((()=>this.highlightOptions),(e=>n.highlightOptions=e),f),u((()=>this.state.id),(()=>n.state=this.state),f)],"map-view"),this._updateStageChildren();const l=this._resolveWhenReady;this._resolveWhenReady=[],l.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:n}=this.state.paddedViewState,r=new j({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",r),this._set("zoom",-1),this._set("rotation",s),this._set("scale",n),this._set("spatialReference",i),this._set("state",null),this.animation=null}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new U(O.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new he({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ce(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(c(this._scaleBeforeChangingSpatialReference))this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[n,r]=t.center;let o=new j({x:n,y:r,spatialReference:t.spatialReference});try{o=this._project(o,e)}catch(p){x()||le.warn(new y("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:o.toJSON(),spatialReference:e,error:p}))}o||(o=new j({x:0,y:0,spatialReference:e}));const l=A(new i({targetGeometry:new j,scale:0,rotation:0}),t.viewpoint,o);s.viewpoint=l;try{const i=20,n=[t.size[0]/2,t.size[1]/2],r=[n[0]+i,n[1]],o=t.toMap([0,0],r),{x:p,y:h}=this._project(new j({x:o[0],y:o[1],spatialReference:t.spatialReference}),e);o[0]=p,o[1]=h,s.toScreen(o,o);const c=Q(n,o,r),d=Math.hypot(o[0]-n[0],o[1]-n[1])/i;!Number.isFinite(d)||Math.abs(d)>4?(l.rotation=0,l.targetGeometry=new j({x:0,y:0,spatialReference:e})):(l.scale*=d,l.scale>a("mapview-srswitch-adjust-rotation-scale-threshold")?l.rotation=0:l.rotation+=Number.isFinite(c)?c:0)}catch{}this._get("constraints").constrain(l,null),this._get("state").viewpoint=l,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};e([_({readOnly:!0})],ye.prototype,"animationManager",void 0),e([_({constructOnly:!0})],ye.prototype,"deactivatedWebGLExtensions",void 0),e([_({constructOnly:!0})],ye.prototype,"debugWebGLExtensions",void 0),e([_({readOnly:!0})],ye.prototype,"featuresTilingScheme",void 0),e([_({readOnly:!0})],ye.prototype,"fullOpacity",void 0),e([_({readOnly:!0})],ye.prototype,"graphicsTileStore",null),e([_()],ye.prototype,"graphicsView",void 0),e([_({readOnly:!0})],ye.prototype,"state",void 0),e([_()],ye.prototype,"initialExtentRequired",null),e([_()],ye.prototype,"labelManager",void 0),e([_({readOnly:!0})],ye.prototype,"resourceManager",null),e([_({readOnly:!0})],ye.prototype,"textureManager",null),e([_({readOnly:!0})],ye.prototype,"mapViewNavigation",void 0),e([_({constructOnly:!0})],ye.prototype,"renderCanvas",void 0),e([_()],ye.prototype,"renderingOptions",void 0),e([_({readOnly:!0})],ye.prototype,"rendering",void 0),e([_({constructOnly:!0})],ye.prototype,"supersampleScreenshotsEnabled",void 0),e([_({readOnly:!0})],ye.prototype,"supportsGround",void 0),e([_()],ye.prototype,"_stationaryTimer",void 0),e([_()],ye.prototype,"_defaultsFromMapSettings",null),e([_()],ye.prototype,"_pePromise",void 0),e([_({readOnly:!0})],ye.prototype,"typeSpecificPreconditionsReady",null),e([_()],ye.prototype,"animation",null),e([_({type:oe})],ye.prototype,"background",null),e([_({value:null,type:j,dependsOn:["state.id","ready"]})],ye.prototype,"center",null),e([_({type:D})],ye.prototype,"constraints",null),e([_({value:null,type:S,dependsOn:["state.id","ready"]})],ye.prototype,"extent",null),e([_()],ye.prototype,"floors",void 0),e([_({type:X})],ye.prototype,"highlightOptions",void 0),e([_({readOnly:!0})],ye.prototype,"inputManager",void 0),e([_()],ye.prototype,"map",void 0),e([_({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],ye.prototype,"padding",null),e([_()],ye.prototype,"resizeAlign",void 0),e([_({readOnly:!0,dependsOn:["state.id"]})],ye.prototype,"resolution",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],ye.prototype,"rotation",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],ye.prototype,"scale",null),e([_({constructOnly:!0})],ye.prototype,"spatialReferenceLocked",void 0),e([_()],ye.prototype,"stationary",null),e([_({type:Y,readOnly:!0})],ye.prototype,"timeline",void 0),e([_({readOnly:!0})],ye.prototype,"type",void 0),e([_({readOnly:!0})],ye.prototype,"updating",null),e([_({value:null,type:i,dependsOn:["state.id","ready"]})],ye.prototype,"viewpoint",null),e([_({value:-1,dependsOn:["state.id"]})],ye.prototype,"zoom",null),e([_({type:Boolean})],ye.prototype,"navigating",null),e([_({type:ae})],ye.prototype,"ui",void 0),ye=e([V("esri.views.MapView")],ye);const ve=ye;function _e(e){const t=e.getObjectId();var i,s,n,r;return t?`${null!=(i=null!=(s=null==(n=e.layer)?void 0:n.uid)?s:null==(r=e.sourceLayer)?void 0:r.uid)?i:"MapView"}/${t}`:`"MapView/${e.uid}`}function Ve(e,i,s,n,r){return a=>{if(a instanceof t){if(a.layer===e)null==r||r();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&(null==n||n(t))}s(_e(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Se(e,t){if(e)if(o(e))for(const i of e)if(o(i))for(const e of i)t(e);else t(i);else t(e)}export{ve as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import i from"../Viewpoint.js";import s from"../core/Collection.js";import n from"../core/CollectionFlattener.js";import r from"../core/Error.js";import a from"../core/has.js";import{isIterable as o}from"../core/iteratorUtils.js";import l from"../core/Logger.js";import{isSome as p,unwrap as h,isNone as c}from"../core/maybe.js";import{throwIfAborted as d}from"../core/promiseUtils.js";import{watch as u,whenOnce as m,sync as g,syncAndInitial as f}from"../core/reactiveUtils.js";import{createScreenPoint as w}from"../core/screenUtils.js";import y from"../core/Warning.js";import{initialize as v}from"../core/workers/workers.js";import{property as _}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import"../core/accessorSupport/ensureType.js";import{subclass as V}from"../core/accessorSupport/decorators/subclass.js";import S from"../geometry/Extent.js";import j from"../geometry/Point.js";import{load as T,canProjectWithoutEngine as R,project as b,isLoaded as x}from"../geometry/projection.js";import{equals as M}from"../geometry/support/spatialReferenceUtils.js";import O from"../layers/support/TileInfo.js";import{BreakpointsOwner as k}from"./BreakpointsOwner.js";import{DOMContainer as z}from"./DOMContainer.js";import{PopupView as L}from"./PopupView.js";import P from"./View.js";import C from"./ViewAnimation.js";import E from"./2d/AnimationManager.js";import G from"./2d/FrameTask.js";import{layerView2DImporter as N}from"./2d/layerViewModuleImportUtils.js";import D from"./2d/MapViewConstraints.js";import q from"./2d/PaddedViewState.js";import"./2d/tiling/PagedTileQueue.js";import U from"./2d/tiling/TileInfoView.js";import"./2d/tiling/TileKey.js";import"./2d/tiling/TileQueue.js";import"./2d/tiling/TileStrategy.js";import{centerAt as A,setExtent as I,rotateTo as F,scaleTo as W,copy as B,create as H,extentToScale as $,resize as J,angleBetween as Q}from"./2d/viewpointUtils.js";import Z from"./2d/input/MapViewInputManager.js";import K from"./2d/layers/features/support/TileStore.js";import X from"./2d/support/HighlightOptions.js";import{Timeline as Y}from"./2d/support/Timeline.js";import ee from"./support/createScreenshotPlan.js";import{getMaximumResolutionScale as te,getFormatAndQuality as ie}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as se,createScreenPointFromSupportedEvent as ne}from"./support/screenUtils.js";import{check as re}from"./support/WebGLRequirements.js";import ae from"./ui/2d/DefaultUI2D.js";import oe from"../webmap/background/ColorBackground.js";const le=l.getLogger("esri.views.MapView");let pe,he,ce,de,ue,me;async function ge(){const[,{GraphicsView2D:e,GraphicContainer:t,LabelManager:i,MapViewNavigation:s,MagnifierView2D:n,Stage:r}]=await Promise.all([import("./2d/webglDeps.js"),import("./2d/mapViewDeps.js")]);he=e,ce=t,de=i,ue=s,me=n,pe=r}const fe=160;function we(e){return e&&"esri.Viewpoint"===e.declaredClass}let ye=class extends(k(z(L(P)))){constructor(e){super(e),this._magnifierView=null,this._stage=null,this._resolveWhenReady=[],this.rootLayerViews=new n({getCollections:()=>{var e,t;return[null==(e=this.basemapView)?void 0:e.baseLayerViews,this.layerViews,null==(t=this.basemapView)?void 0:t.referenceLayerViews]},getChildrenFunction:()=>null}),this.featuresTilingScheme=null,this.fullOpacity=1,this.graphicsView=null,this.labelManager=null,this.mapViewNavigation=null,this.renderingOptions={samplingMode:"dynamic",edgeLabelsVisible:!0,labelsAnimationTime:125,labelCollisionsEnabled:!0},this.rendering=!1,this.supersampleScreenshotsEnabled=!1,this.supportsGround=!1,this._stationaryTimer=null,this.frameTask=new G(this),this._pePromise=null,this.floors=new s,this.highlightOptions=new X,this.inputManager=new Z({view:this}),this.map=null,this.resizeAlign="center",this.spatialReferenceLocked=!1,this.timeline=new Y,this.type="2d",this.ui=new ae,this.constraints=new D,this.padding={top:0,right:0,bottom:0,left:0},this.handles.add([u((()=>this.viewpoint),(()=>{this._lastStationaryEventTimestamp=performance.now(),this._flipStationary(fe)}),g),this.on("resize",(e=>this._resizeHandler(e))),u((()=>{var e;return null==(e=this.animationManager)?void 0:e.animation}),(e=>{this.animation=e}))]),v()}destroy(){this._set("preconditionsReady",!1),this._gotoTask=this.frameTask=null,this.rootLayerViews.destroy(),this.inputManager.destroy(),this._set("inputManager",null)}get graphicsTileStore(){return new K(this.featuresTilingScheme)}get initialExtentRequired(){var e;const{scale:t,constraints:i,center:s,viewpoint:n,extent:r}=this;let a=this.zoom;return!(this.map&&"initialViewProperties"in this.map&&null!=(e=this.map.initialViewProperties)&&e.viewpoint)&&(!r&&(null!=i&&i.effectiveLODs||(a=-1),(!s||0===t&&-1===a)&&(!n||!p(n.targetGeometry)||"extent"!==n.targetGeometry.type&&!n.scale)))}get resourceManager(){return this._stage.resourceManager}get textureManager(){return this._stage.painter.textureManager}get _defaultsFromMapSettings(){return{required:{tileInfo:!0,heightModelInfo:!1,extent:!1},requiresExtentInSpatialReference:this.spatialReferenceLocked}}get _projectionEngineLoaded(){return!!x()||(this._pePromise||(this._pePromise=T().finally((()=>{this._pePromise=null}))),!1)}get typeSpecificPreconditionsReady(){const e=this._getDefaultViewpoint();if(!e)return!1;const t=this.spatialReference,i=h(e.targetGeometry);return!!R(i.spatialReference,t)||this._projectionEngineLoaded}set animation(e){const t=this._get("animation");if(e===t)return;if(t&&t.stop(),!e||e.isFulfilled())return void this._set("animation",null);this._set("animation",e),this.frameTask.animationInProgress=!0;const i=()=>{e===this._get("animation")&&(this._set("animation",null),this.frameTask.requestFrame()),this.frameTask.animationInProgress=!1};e.when(i,i)}get background(){return this.get("map.initialViewProperties.background")||null}set background(e){void 0===e?this._clearOverride("background"):this._override("background",e)}get center(){if(!this.ready)return this._get("center");const{center:e,spatialReference:t}=this.state.paddedViewState;return new j({x:e[0],y:e[1],spatialReference:t})}set center(e){if(null==e)return;if(!this.ready)return this._set("center",e),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void le.error(new r("mapview:invalid-center","could not project the value in the view's spatial reference",{input:e,error:s}))}const i=this.viewpoint;A(i,i,t),this.viewpoint=i}set constraints(e){const t=this._get("constraints");t&&(this.handles.remove("map-view-constraints"),t.destroy()),this._set("constraints",e),e&&(e.view=this,this.ready&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint)),this.handles.add(u((()=>e.version),(()=>{this.ready&&this.state&&(this.state.viewpoint=e.fit(this.state.paddedViewState.viewpoint))}),g),"map-view-constraints"))}get extent(){return this.ready?this.state.paddedViewState.extent.clone():this._get("extent")}set extent(e){if(null==e)return;if(!e.width||!e.height)return void le.error(new r("mapview:invalid-extent","invalid extent size"));if(!this.ready)return this._set("extent",e),this._set("center",null),this._set("viewpoint",null),this._set("scale",0),this._set("zoom",-1),void this.notifyChange("initialExtentRequired");let t;try{t=this._project(e,this.spatialReference)}catch(s){return void le.error(new r("mapview:invalid-extent","could not project the value in the view's spatial reference",{error:s}))}const i=this.viewpoint;I(i,i,t,this.size,{constraints:this.constraints}),this.viewpoint=i}get padding(){return this.ready?this.state.padding:this._get("padding")}set padding(e){this.ready?(this.state.padding=e,this._set("padding",this.state.padding)):this._set("padding",e)}get resolution(){return this.state?this.state.resolution:0}get rotation(){return this.ready?this.state.rotation:this._get("rotation")}set rotation(e){if(isNaN(e))return;if(!this.ready)return void this._set("rotation",e);const t=this.viewpoint;F(t,t,e),this.viewpoint=t}get scale(){return this.ready?this.state.scale:this._get("scale")}set scale(e){if(!e||isNaN(e))return;if(!this.ready){this._set("scale",e),this._set("zoom",-1);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}const t=this.viewpoint;W(t,t,e),this.viewpoint=t}get stationary(){return!(this.animation||this.navigating||this.resizing||this._stationaryTimer)}get updating(){return!this.destroyed&&(!this.layerViewManager||!this.labelManager||!this.graphicsView||!0===this.layerViewManager.updating||!0===this.labelManager.updating||!0===this.graphicsView.updating||this.allLayerViews.some((e=>!e.destroyed&&!("layerViews"in e)&&!0===e.updating)))}get viewpoint(){if(!this.ready)return this._get("viewpoint");const e=this.state.paddedViewState;return e&&e.viewpoint.clone()}set viewpoint(e){if(null==e)return;if(!this.ready)return this._set("viewpoint",e),this._set("extent",null),this._set("center",null),this._set("zoom",-1),this._set("scale",0),void this.notifyChange("initialExtentRequired");let t,s;try{t=this._project(e,this.spatialReference),!e.scale||isNaN(e.scale)?s=new r("mapview:invalid-viewpoint",`invalid scale value of ${e.scale}`):c(e.targetGeometry)&&(s=new r("mapview:invalid-viewpoint","geometry not defined"))}catch(a){s=new r("mapview:invalid-viewpoint","could not project the value in the view's spatial reference",{error:a})}if(s)return void le.error(s);this._scaleBeforeChangingSpatialReference=null;const n=new i({targetGeometry:new j,scale:0,rotation:0});B(n,t),this.constraints.constrain(n,this.state.paddedViewState.viewpoint),this.state.viewpoint=n,this.frameTask.requestFrame(),this._set("viewpoint",n)}get zoom(){return this.ready?this.constraints.scaleToZoom(this.scale):this._get("zoom")}set zoom(e){if(null==e)return;if(!this.ready){this._set("zoom",e),this._set("scale",0);const t=this._get("extent");return t&&(this._set("extent",null),this._set("center",t.center)),void this.notifyChange("initialExtentRequired")}if(!this.constraints.effectiveLODs)return void this._set("zoom",-1);const t=this.viewpoint;W(t,t,this.constraints.zoomToScale(e)),this.viewpoint=t,this._set("zoom",this.constraints.scaleToZoom(this.scale))}get navigating(){return!(!this.mapViewNavigation||!this.mapViewNavigation.interacting)}goTo(e,t){if(e)return this.animation&&(this.animation=null),this._createAnimation(),m((()=>this.ready),t).then((()=>{const i={animate:!0,...t},s=H(e,this);return this.animation.update(s),this._gotoTask={},i.animate?this._gotoAnimated(s,i):this._gotoImmediate(s,i)}));le.error("#goTo()","target cannot be null or undefined")}async hitTest(e,t){const i=se(e)?ne(this,e):e;if(!this.ready||isNaN(i.x)||isNaN(i.y))return{screenPoint:i,results:[]};let s=new Set,n=!1,r=null,a=null;null!=t&&t.include?Se(t.include,Ve(this,(e=>s.add(e)),(e=>{r||(r=new Set),r.add(e)}),(e=>s.add(e)),(()=>n=!0))):(n=!0,s=new Set(this.allLayerViews)),null!=t&&t.exclude&&Se(t.exclude,Ve(this,(e=>s.delete(e)),(e=>{a||(a=new Set),a.add(e)})));const o=this.allLayerViews.filter((e=>!e.suspended&&s.has(e))).reverse(),l=this.toMap(i);let h=(await Promise.all([n?this.graphicsView.hitTest(l):null,...o.map((e=>e.hitTest(l,i)))])).filter(p).flat();return r&&(h=h.filter((e=>r.has(_e(e))))),a&&(h=h.filter((e=>!a.has(_e(e))))),{screenPoint:i,results:h.map((e=>({mapPoint:l,graphic:e})))}}takeScreenshot(e){e=e||{};const t=this.supersampleScreenshotsEnabled?Math.min(4,te(this.size,Math.min(4096,this._stage.context.parameters.maxTextureSize))):1;let i;e.layers?(i=[],e.layers.forEach((e=>{const t=this.allLayerViews.find((t=>t.layer.id===e.id));t&&"container"in t&&t.container&&i.push(t.container)}))):i=this._stage.children;const{format:s,quality:n}=ie(e.format,e.quality),r=ee(e,t,this.size,this.padding,s,n,i,e.rotation);return this._stage.takeScreenshot(r)}toMap(e){if(!this.ready)return null;const t=se(e)?ne(this,e):e,i=[0,0],[s,n]=this.state.toMap(i,[t.x,t.y]),r=this.spatialReference;return new j({x:s,y:n,spatialReference:r})}toScreen(e){if(!this.ready)return null;const t=this._project(e,this.spatialReference),i=[t.x,t.y];return this.state.toScreen(i,i),w(i[0],i[1])}on(e,t,i,s){const n=this.inputManager&&this.viewEvents.on(e,t,i,s);return n||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}whenLayerView(e){return super.whenLayerView(e)}graphicChanged(e){if(this.graphicsView){this.graphicsView.graphicUpdateHandler(e)}}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||null}hasLayerViewModule(e){return N.hasLayerViewModule(e)}importLayerView(e){return N.importLayerView(e)}pixelSizeAt(){return this.ready?this.state.resolution:(le.error("#pixelSizeAt()","Map view cannot be used before it is ready"),null)}popupHitTest(e){return this.hitTest(e).then((t=>({...t,mapPoint:this.toMap(e)})))}requestUpdate(){this.ready&&this.frameTask.requestUpdate()}validate(){let e=re(this.type);return a("safari")&&a("safari")<9&&(e=new r("mapview:browser-not-supported","This browser is not supported by MapView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:a("safari")})),p(e)?(le.warn("#validate()",e.message),Promise.reject(e)):ge()}_createAnimation(){return this.animation&&!this.animation.done||(this.animation=new C),this.animation}_cancellableGoTo(e,t,i){const s=()=>e===this._gotoTask,n=i.then((()=>{s()&&(this.animation=null)})).catch((e=>{throw s()&&(this.animation=null,t.done||(t.stop(),this.frameTask.animationInProgress=!1)),e})),r=new Promise((e=>e(n)));return t.when().catch((()=>{s()&&r.cancel&&r.cancel()})),r}_gotoImmediate(e,t){const i=this._gotoTask,s=this.animation,n=e.then((e=>{if(d(t),i!==this._gotoTask)throw new r("view:goto-interrupted","Goto was interrupted");this.viewpoint=s.target=e,s.finish()}));return this._cancellableGoTo(i,s,n)}_flipStationary(e){return null!==this._stationaryTimer||(this._stationaryTimer=setTimeout((()=>{this._stationaryTimer=null;const e=performance.now()-this._lastStationaryEventTimestamp;e<fe&&(this._stationaryTimer=this._flipStationary(e))}),e)),this._stationaryTimer}_getDefaultViewpoint(){var e,t,s,n;const{constraints:r,initialExtent:a,map:o}=this;if(!r)return null;const l=o&&"initialViewProperties"in o&&o.initialViewProperties,c={zoom:this._get("zoom"),scale:this._get("scale"),center:this._get("center"),extent:this._get("extent"),rotation:this._get("rotation"),viewpoint:this._get("viewpoint"),spatialReference:this._userSpatialReference};r.effectiveLODs?-1!==c.zoom&&(c.scale=r.zoomToScale(c.zoom)):c.zoom=-1;let d=null,u=null,m=0;const g=c.viewpoint&&c.viewpoint.rotation,f=c.viewpoint&&c.viewpoint.targetGeometry;p(f)&&("extent"===f.type?d=f:"point"===f.type&&(u=f,m=c.viewpoint.scale));const w=c.extent||d||(null==(e=h(null==l||null==(t=l.viewpoint)?void 0:t.targetGeometry))?void 0:e.extent)||a,y=c.center||u||(null==w?void 0:w.center),v=c.scale||m||(null==l||null==(s=l.viewpoint)?void 0:s.scale)||w&&$(w,this.size),_=c.rotation||g||(null==l||null==(n=l.viewpoint)?void 0:n.rotation)||0;return y&&v?new i({targetGeometry:y,scale:v,rotation:_}):null}_gotoAnimated(e,t){const i=this._gotoTask,s=this.animation,n=e.then((e=>{if(d(t),i!==this._gotoTask)throw new r("view:goto-interrupted","Goto was interrupted");return s.update(e),this.animationManager.animate(s,this.viewpoint,t),s.when().then((()=>{}),(()=>{}))}));return this._cancellableGoTo(i,s,n)}_project(e,t){var i;const s=e&&e.targetGeometry||e;if(!t)return e;if(!s)return null;if(t.imageCoordinateSystem||null!=(i=s.spatialReference)&&i.imageCoordinateSystem)return e;if(M(t,s.spatialReference))return e;const n=b(s,t);if(!n)throw new r("mapview:projection-not-possible","projecting input geometry to target spatial reference returned a null value",{geometry:s,spatialReference:t});return we(e)?(e.targetGeometry=n,e):n}_resizeHandler(e){if(!this.ready)return;const t=this.state;let i=this.state.paddedViewState.viewpoint;const s=this.state.paddedViewState.size.concat();t.size=[e.width,e.height],J(i,i,s,this.state.paddedViewState.size,this.resizeAlign),i=this.constraints.constrain(i,null),this.state.viewpoint=i}_startup(){var e;this.timeline.begin("MapView Startup");const t=this._getDefaultViewpoint(),i=t.targetGeometry;try{this._project(t,this.spatialReference)}catch(p){var s;le.warn(new y("mapview:startup-projection-error","projection of initial viewpoint to the view's spatial reference, defaulting to the initial viewpoint.",{center:i.toJSON(),spatialReference:this.spatialReference,error:p})),t.targetGeometry=(null==(s=this.defaultsFromMap.extent)?void 0:s.center)||new j({x:0,y:0,spatialReference:this.spatialReference})}null==(e=this.constraints)||e.fit(t),this._set("state",new q({padding:this._get("padding"),size:this.size,viewpoint:t})),this.graphics.owner=this;const n=new pe(this.surface,{canvas:this.renderCanvas,supersampleScreenshots:this.supersampleScreenshotsEnabled,contextOptions:{disabledExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions},renderingOptions:this.renderingOptions,timeline:this.timeline});this._stage=n,this._magnifierView=new me,this._magnifierView.magnifier=this.magnifier;const r=new de({view:this});this._set("labelManager",r);const a=new E({view:this});this._set("animationManager",a);const o=new ue({view:this,animationManager:a});this._set("mapViewNavigation",o),this._setupSpatialReferenceDependentProperties(),this.handles.add([this.rootLayerViews.on("change",(()=>this._updateStageChildren())),n.on("post-render",(()=>this._set("rendering",n.renderRequested))),n.on("will-render",(()=>this._set("rendering",n.renderRequested))),n.on("webgl-error",(e=>this.fatalError=e.error)),u((()=>this.stationary),(e=>n.stationary=e),f),u((()=>this.background),(e=>{n.background=e,this._magnifierView.background=e}),f),u((()=>this.magnifier),(e=>this._magnifierView.magnifier=e),f),u((()=>this.renderingOptions),(e=>n.renderingOptions=e),f),u((()=>this.highlightOptions),(e=>n.highlightOptions=e),f),u((()=>this.state.id),(()=>n.state=this.state),f)],"map-view"),this._updateStageChildren();const l=this._resolveWhenReady;this._resolveWhenReady=[],l.forEach((e=>e(this))),this.timeline.end("MapView Startup"),this.frameTask&&this.frameTask.start(),this._set("ready",!0)}_teardown(){this._destroySpatialReferenceDependentProperties(),this.handles.remove("map-view"),this.mapViewNavigation.destroy(),this._set("mapViewNavigation",null),this.animationManager.destroy(),this._set("animationManager",null),this.layerViewManager.clear(),this.labelManager.destroy(),this._magnifierView.destroy(),this._stage.destroy(),this._stage=null,this._set("graphicsView",null),this._magnifierView=null,this._set("labelManager",null),this._set("mapViewNavigation",null),this.graphics.owner=null,this.frameTask&&this.frameTask.stop(),this._stationaryTimer&&(clearTimeout(this._stationaryTimer),this._stationaryTimer=null),this._set("ready",!1);const{center:[e,t],spatialReference:i,rotation:s,scale:n}=this.state.paddedViewState,r=new j({x:e,y:t,spatialReference:i});this._set("viewpoint",null),this._set("extent",null),this._set("center",r),this._set("zoom",-1),this._set("rotation",s),this._set("scale",n),this._set("spatialReference",i),this._set("state",null),this.animation=null}_updateStageChildren(){this._stage.removeAllChildren(),this.rootLayerViews.forEach((e=>{this._stage.addChild(e.container)}));const e=this.graphicsView;this._stage.addChild(e.container),this._stage.addChild(this._magnifierView)}_setupSpatialReferenceDependentProperties(){const e=new U(O.create({spatialReference:this.spatialReference,size:512,numLODs:36}));this._set("featuresTilingScheme",e);const t=new he({view:this,graphics:this.graphics,requestUpdateCallback:()=>this.requestUpdate(),container:new ce(e)});this.frameTask.graphicsView=t,this._set("graphicsView",t)}_destroySpatialReferenceDependentProperties(){const e=this.graphicsView;this._set("graphicsView",null),this.frameTask.graphicsView=null,e.destroy(),this._set("featuresTilingScheme",null)}_spatialReferenceChanged(e){if(!this.ready)return;this.frameTask.stop();for(const i of this.allLayerViews)i.processDetach();this._destroySpatialReferenceDependentProperties();const t=this.state.paddedViewState.clone();if(c(this._scaleBeforeChangingSpatialReference))this._scaleBeforeChangingSpatialReference=t.scale;else{const e=t.viewpoint.clone();e.scale=this._scaleBeforeChangingSpatialReference,t.viewpoint=e}const s=t.clone(),[n,r]=t.center;let o=null;try{o=this._project(new j({x:n,y:r,spatialReference:t.spatialReference}),e)}catch(p){x()||le.warn(new y("mapview:spatial-reference-change","could not project the view's center to the new spatial reference",{center:o.toJSON(),spatialReference:e,error:p}))}o||(o=new j({x:0,y:0,spatialReference:e}));const l=A(new i({targetGeometry:new j,scale:0,rotation:0}),t.viewpoint,o);s.viewpoint=l;try{const i=20,n=[t.size[0]/2,t.size[1]/2],r=[n[0]+i,n[1]],o=t.toMap([0,0],r),{x:p,y:h}=this._project(new j({x:o[0],y:o[1],spatialReference:t.spatialReference}),e);o[0]=p,o[1]=h,s.toScreen(o,o);const c=Q(n,o,r),d=Math.hypot(o[0]-n[0],o[1]-n[1])/i;!Number.isFinite(d)||Math.abs(d)>4?(l.rotation=0,l.targetGeometry=new j({x:0,y:0,spatialReference:e})):(l.scale*=d,l.scale>a("mapview-srswitch-adjust-rotation-scale-threshold")?l.rotation=0:l.rotation+=Number.isFinite(c)?c:0)}catch{}this._get("constraints").constrain(l,null),this._get("state").viewpoint=l,this._stage.state=this.state,this._setupSpatialReferenceDependentProperties();for(const i of this.allLayerViews)i.processAttach();this.frameTask.requestFrame(),this.frameTask.start(),this._updateStageChildren()}};e([_({readOnly:!0})],ye.prototype,"animationManager",void 0),e([_({constructOnly:!0})],ye.prototype,"deactivatedWebGLExtensions",void 0),e([_({constructOnly:!0})],ye.prototype,"debugWebGLExtensions",void 0),e([_({readOnly:!0})],ye.prototype,"featuresTilingScheme",void 0),e([_({readOnly:!0})],ye.prototype,"fullOpacity",void 0),e([_({readOnly:!0})],ye.prototype,"graphicsTileStore",null),e([_()],ye.prototype,"graphicsView",void 0),e([_({readOnly:!0})],ye.prototype,"state",void 0),e([_()],ye.prototype,"initialExtentRequired",null),e([_()],ye.prototype,"labelManager",void 0),e([_({readOnly:!0})],ye.prototype,"resourceManager",null),e([_({readOnly:!0})],ye.prototype,"textureManager",null),e([_({readOnly:!0})],ye.prototype,"mapViewNavigation",void 0),e([_({constructOnly:!0})],ye.prototype,"renderCanvas",void 0),e([_()],ye.prototype,"renderingOptions",void 0),e([_({readOnly:!0})],ye.prototype,"rendering",void 0),e([_({constructOnly:!0})],ye.prototype,"supersampleScreenshotsEnabled",void 0),e([_({readOnly:!0})],ye.prototype,"supportsGround",void 0),e([_()],ye.prototype,"_stationaryTimer",void 0),e([_()],ye.prototype,"_defaultsFromMapSettings",null),e([_()],ye.prototype,"_pePromise",void 0),e([_({readOnly:!0})],ye.prototype,"typeSpecificPreconditionsReady",null),e([_()],ye.prototype,"animation",null),e([_({type:oe})],ye.prototype,"background",null),e([_({value:null,type:j,dependsOn:["state.id","ready"]})],ye.prototype,"center",null),e([_({type:D})],ye.prototype,"constraints",null),e([_({value:null,type:S,dependsOn:["state.id","ready"]})],ye.prototype,"extent",null),e([_()],ye.prototype,"floors",void 0),e([_({type:X})],ye.prototype,"highlightOptions",void 0),e([_({readOnly:!0})],ye.prototype,"inputManager",void 0),e([_()],ye.prototype,"map",void 0),e([_({value:{top:0,right:0,bottom:0,left:0},cast:e=>({top:0,right:0,bottom:0,left:0,...e})})],ye.prototype,"padding",null),e([_()],ye.prototype,"resizeAlign",void 0),e([_({readOnly:!0,dependsOn:["state.id"]})],ye.prototype,"resolution",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],ye.prototype,"rotation",null),e([_({value:0,type:Number,dependsOn:["state.id","ready"]})],ye.prototype,"scale",null),e([_({constructOnly:!0})],ye.prototype,"spatialReferenceLocked",void 0),e([_()],ye.prototype,"stationary",null),e([_({type:Y,readOnly:!0})],ye.prototype,"timeline",void 0),e([_({readOnly:!0})],ye.prototype,"type",void 0),e([_({readOnly:!0})],ye.prototype,"updating",null),e([_({value:null,type:i,dependsOn:["state.id","ready"]})],ye.prototype,"viewpoint",null),e([_({value:-1,dependsOn:["state.id"]})],ye.prototype,"zoom",null),e([_({type:Boolean})],ye.prototype,"navigating",null),e([_({type:ae})],ye.prototype,"ui",void 0),ye=e([V("esri.views.MapView")],ye);const ve=ye;function _e(e){const t=e.getObjectId();var i,s,n,r;return t?`${null!=(i=null!=(s=null==(n=e.layer)?void 0:n.uid)?s:null==(r=e.sourceLayer)?void 0:r.uid)?i:"MapView"}/${t}`:`"MapView/${e.uid}`}function Ve(e,i,s,n,r){return a=>{if(a instanceof t){if(a.layer===e)null==r||r();else{const t=e.allLayerViews.find((e=>e.layer===a.layer));t&&(null==n||n(t))}s(_e(a))}else{const t=e.allLayerViews.find((e=>e.layer===a));t&&i(t)}}}function Se(e,t){if(e)if(o(e))for(const i of e)if(o(i))for(const e of i)t(e);else t(i);else t(e)}export{ve 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import i from"../../core/Collection.js";import{castForReferenceSetter as s,referenceSetter as r}from"../../core/collectionUtils.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import l from"./LayerView.js";let o=class extends l{constructor(e){super(e),this.type="group",this.layerViews=new i}initialize(){this.handles.add([this.layerViews.on("change",(e=>this._layerViewsChangeHandler(e))),this.layerViews.on("after-changes",(()=>this._layerViewsAfterChangesHandler())),this.layer.watch("visibilityMode",(()=>this._visibilityModeHandler()),!0),this.watch("visible",(()=>this._visibleHandler()),!0)],"grouplayerview"),this._layerViewsChangeHandler({target:null,added:this.layerViews.toArray(),removed:[],moved:[]}),this._layerViewsAfterChangesHandler()}set layerViews(e){this._set("layerViews",r(e,this._get("layerViews")))}isUpdating(){return this.layerViews.some((e=>e.updating))}get updatingProgress(){return 0===this.layerViews.length?1:this.layerViews.reduce(((e,i)=>e+i.updatingProgress),0)/this.layerViews.length}_hasLayerViewVisibleOverrides(){return this.layerViews.some((e=>e._isOverridden("visible")))}_findLayerViewForLayer(e){return e&&this.layerViews.find((i=>i.layer===e))}_firstVisibleOnLayerOrder(){const e=this.layer.layers.find((e=>{const i=this._findLayerViewForLayer(e);return i&&i.visible}));return e&&this._findLayerViewForLayer(e)}_enforceExclusiveVisibility(e){this._hasLayerViewVisibleOverrides()&&(e||!(e=this._firstVisibleOnLayerOrder())&&this.layerViews.length>0&&(e=this._findLayerViewForLayer(this.layer.layers.getItemAt(0))),this.layerViews.forEach((i=>{i.visible=i===e})))}_layerViewsChangeHandler(e){this.handles.remove("grouplayerview:visible"),this.handles.add(this.layerViews.map((e=>e.watch("visible",(i=>this._layerViewVisibleHandler(i,e)),!0))).toArray(),"grouplayerview:visible");const i=e.added[e.added.length-1];let s=null;i&&i.visible&&(s=i),this._enforceVisibility(s)}_layerViewsAfterChangesHandler(){this.handles.remove("grouplayerview:updating"),this.handles.add(this.layerViews.map((e=>e.watch("updating",(()=>this._updateUpdating()),!0))).toArray(),"grouplayerview:updating"),this._updateUpdating()}_enforceVisibility(e){if(this._hasLayerViewVisibleOverrides())switch(this.layer.visibilityMode){case"inherited":{const e=this.visible;this.layerViews.forEach((i=>{i.visible=e}));break}case"exclusive":this._enforceExclusiveVisibility(e)}}_visibilityModeHandler(){this._enforceVisibility()}_layerViewVisibleHandler(e,i){if(this._hasLayerViewVisibleOverrides())switch(this.layer.visibilityMode){case"inherited":e!==this.visible&&(i.visible=this.visible);break;case"exclusive":this._enforceExclusiveVisibility(e&&i)}}_visibleHandler(){var e;this._hasLayerViewVisibleOverrides()&&"inherited"===(null==(e=this.layer)?void 0:e.visibilityMode)&&this._enforceVisibility()}_updateUpdating(){this.notifyChange("updating")}};e([t({cast:s})],o.prototype,"layerViews",null),e([t()],o.prototype,"view",void 0),e([t({readOnly:!0})],o.prototype,"updatingProgress",null),o=e([a("esri.views.layers.GroupLayerView")],o);const h=o;export{h as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import i from"../../core/Collection.js";import{castForReferenceSetter as s,referenceSetter as r}from"../../core/collectionUtils.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import a from"./LayerView.js";let o=class extends a{constructor(e){super(e),this.type="group",this.layerViews=new i}initialize(){this.handles.add([this.layerViews.on("change",(e=>this._layerViewsChangeHandler(e))),this.layer.watch("visibilityMode",(()=>this._visibilityModeHandler()),!0),this.watch("visible",(()=>this._visibleHandler()),!0)],"grouplayerview"),this._layerViewsChangeHandler({target:null,added:this.layerViews.toArray(),removed:[],moved:[]})}set layerViews(e){this._set("layerViews",r(e,this._get("layerViews")))}get updatingProgress(){return 0===this.layerViews.length?1:this.layerViews.reduce(((e,i)=>e+i.updatingProgress),0)/this.layerViews.length}isUpdating(){return this.layerViews.some((e=>e.updating))}_hasLayerViewVisibleOverrides(){return this.layerViews.some((e=>e._isOverridden("visible")))}_findLayerViewForLayer(e){return e&&this.layerViews.find((i=>i.layer===e))}_firstVisibleOnLayerOrder(){const e=this.layer.layers.find((e=>{const i=this._findLayerViewForLayer(e);return i&&i.visible}));return e&&this._findLayerViewForLayer(e)}_enforceExclusiveVisibility(e){this._hasLayerViewVisibleOverrides()&&(e||!(e=this._firstVisibleOnLayerOrder())&&this.layerViews.length>0&&(e=this._findLayerViewForLayer(this.layer.layers.getItemAt(0))),this.layerViews.forEach((i=>{i.visible=i===e})))}_layerViewsChangeHandler(e){this.handles.remove("grouplayerview:visible"),this.handles.add(this.layerViews.map((e=>e.watch("visible",(i=>this._layerViewVisibleHandler(i,e)),!0))).toArray(),"grouplayerview:visible");const i=e.added[e.added.length-1];let s=null;i&&i.visible&&(s=i),this._enforceVisibility(s)}_enforceVisibility(e){if(this._hasLayerViewVisibleOverrides())switch(this.layer.visibilityMode){case"inherited":{const e=this.visible;this.layerViews.forEach((i=>{i.visible=e}));break}case"exclusive":this._enforceExclusiveVisibility(e)}}_visibilityModeHandler(){this._enforceVisibility()}_layerViewVisibleHandler(e,i){if(this._hasLayerViewVisibleOverrides())switch(this.layer.visibilityMode){case"inherited":e!==this.visible&&(i.visible=this.visible);break;case"exclusive":this._enforceExclusiveVisibility(e&&i)}}_visibleHandler(){var e;this._hasLayerViewVisibleOverrides()&&"inherited"===(null==(e=this.layer)?void 0:e.visibilityMode)&&this._enforceVisibility()}};e([t({cast:s})],o.prototype,"layerViews",null),e([t({readOnly:!0})],o.prototype,"updatingProgress",null),e([t()],o.prototype,"view",void 0),o=e([l("esri.views.layers.GroupLayerView")],o);const h=o;export{h 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.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{isNone as a,isSome as t}from"../../../core/maybe.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{isTiledLayer as r,isWMTSLayer as n}from"../../../layers/support/layerUtils.js";import{stringFromViewingMode as o,ViewingMode as s}from"../../../views/ViewingMode.js";import{getTileInfoAndExtentFromWMTSLayer as l,isVectorTileLayer as p,checkIfTileInfoSupportedForView as c}from"../../../views/3d/terrain/terrainUtils.js";import m from"../../../views/3d/terrain/TilingScheme.js";import{isSpatialReferenceSupported as f}from"../../../views/support/spatialReferenceSupport.js";async function u(e,a={}){await b(e,a),i(a)}async function y(e,a={}){const{basemap:t,view:n}=e;if("spatialReferenceLocked"in n&&!n.spatialReferenceLocked)return;if(await t.load(a),i(a),0===t.baseLayers.length)return;const o=t.baseLayers.getItemAt(0);if(!r(o))return;if(t.spatialReference){if(n.spatialReference.equals(t.spatialReference))return;w()}await o.load(a),i(a);const s=(("supportedSpatialReferences"in o?o.supportedSpatialReferences:null)||["tileInfo"in o?o.tileInfo.spatialReference:null]).filter(Boolean);0!==s.length&&s.every((e=>!n.spatialReference.equals(e)))&&w()}function w(){throw new e("basemap-compatibility:incompatible-spatial-reference","Basemap spatial reference is not compatible with the view")}async function b(a,t){const{basemap:i,view:r}=a;if(await i.load(t),0===i.baseLayers.length)return;const n=h(i.baseLayers.concat(i.referenceLayers));if(n.length)throw n[0];const o=i.baseLayers.getItemAt(0);try{await o.load(t)}catch(s){const a="basemap-compatibility:unknown-error",t="Unknown basemap compatibility error",{name:i=a,message:r=t,details:n}=s;throw new e(i,r,n)}g(o,r)}function h(a){const t=["ArcGISTiledImageServiceLayer","ArcGISTiledMapServiceLayer","OpenStreetMap","VectorTileLayer","WebTiledLayer"];return a.toArray().filter((e=>-1===t.indexOf(e.operationalLayerType))).map((a=>new e("basemap-compatibility:unsupported-basemap-layer-type","Unsupported basemap layer type ${operationalLayerType}",{layer:a,operationalLayerType:a.operationalLayerType||"unknown"})))}function g(i,r){const u=r.state.viewingMode;if(!u)return;let y=i.tileInfo,w=i.fullExtent;if(n(i)){const t=l(i,r.spatialReference,u);if(a(t.tileInfo))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view");y=t.tileInfo,w=t.fullExtent}if(a(y))return;if(!f(y.spatialReference,u))throw new e(`basemapgalleryitem:spatial-reference-unsupported-${o(u)}`,`Basemap spatial reference is unsupported in ${o(u)} mode`);const b=y.spatialReference.isGeographic,h=p(i)?y.getOrCreateCompatible(256,b?1:2):null;if(u===s.Global){let a=c(y,w,null,u);if(a&&p(i)&&t(w)&&h&&!c(h,w,null,u)&&(a=null),a){const t=y.spatialReference.isWebMercator?"web-mercator":"wgs84";throw new e(`basemapgalleryitem:tiling-scheme-unsupported-${t}-global`,"Basemap tiling scheme is unsupported in global mode",{error:a})}}else if(m.checkUnsupported(y))throw new e("basemapgalleryitem:tiling-scheme-unsupported-local","Basemap tiling scheme is unsupported in local mode");const g=r.get("basemapTerrain.tilingScheme");if(g&&!g.compatibleWith(y)&&!(p(i)&&h&&g.compatibleWith(h)))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view")}export{y as default2DCompatibility,u as default3DCompatibility};
5
+ import e from"../../../core/Error.js";import{isNone as a,isSome as t}from"../../../core/maybe.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{isTiledLayer as r,isWMTSLayer as n}from"../../../layers/support/layerUtils.js";import{stringFromViewingMode as o,ViewingMode as s}from"../../../views/ViewingMode.js";import{getTileInfoAndExtentFromWMTSLayer as l,isVectorTileLayer as p,checkIfTileInfoSupportedForView as c}from"../../../views/3d/terrain/terrainUtils.js";import m from"../../../views/3d/terrain/TilingScheme.js";import{isSpatialReferenceSupported as f}from"../../../views/support/spatialReferenceSupport.js";async function u(e,a={}){await b(e,a),i(a)}async function y(e,a={}){const{basemap:t,view:n}=e;if(i(a),"spatialReferenceLocked"in n&&!n.spatialReferenceLocked)return;if(await t.load(a),i(a),0===t.baseLayers.length)return;const o=t.baseLayers.getItemAt(0);if(!r(o))return;if(t.spatialReference){if(n.spatialReference.equals(t.spatialReference))return;w()}await o.load(a),i(a);const s=(("supportedSpatialReferences"in o?o.supportedSpatialReferences:null)||["tileInfo"in o?o.tileInfo.spatialReference:null]).filter(Boolean);0!==s.length&&s.every((e=>!n.spatialReference.equals(e)))&&w()}function w(){throw new e("basemap-compatibility:incompatible-spatial-reference","Basemap spatial reference is not compatible with the view")}async function b(a,t){const{basemap:i,view:r}=a;if(await i.load(t),0===i.baseLayers.length)return;const n=h(i.baseLayers.concat(i.referenceLayers));if(n.length)throw n[0];const o=i.baseLayers.getItemAt(0);try{await o.load(t)}catch(s){const a="basemap-compatibility:unknown-error",t="Unknown basemap compatibility error",{name:i=a,message:r=t,details:n}=s;throw new e(i,r,n)}g(o,r)}function h(a){const t=["ArcGISTiledImageServiceLayer","ArcGISTiledMapServiceLayer","OpenStreetMap","VectorTileLayer","WebTiledLayer"];return a.toArray().filter((e=>-1===t.indexOf(e.operationalLayerType))).map((a=>new e("basemap-compatibility:unsupported-basemap-layer-type","Unsupported basemap layer type ${operationalLayerType}",{layer:a,operationalLayerType:a.operationalLayerType||"unknown"})))}function g(i,r){const u=r.state.viewingMode;if(!u)return;let y=i.tileInfo,w=i.fullExtent;if(n(i)){const t=l(i,r.spatialReference,u);if(a(t.tileInfo))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view");y=t.tileInfo,w=t.fullExtent}if(a(y))return;if(!f(y.spatialReference,u))throw new e(`basemapgalleryitem:spatial-reference-unsupported-${o(u)}`,`Basemap spatial reference is unsupported in ${o(u)} mode`);const b=y.spatialReference.isGeographic,h=p(i)?y.getOrCreateCompatible(256,b?1:2):null;if(u===s.Global){let a=c(y,w,null,u);if(a&&p(i)&&t(w)&&h&&!c(h,w,null,u)&&(a=null),a){const t=y.spatialReference.isWebMercator?"web-mercator":"wgs84";throw new e(`basemapgalleryitem:tiling-scheme-unsupported-${t}-global`,"Basemap tiling scheme is unsupported in global mode",{error:a})}}else if(m.checkUnsupported(y))throw new e("basemapgalleryitem:tiling-scheme-unsupported-local","Basemap tiling scheme is unsupported in local mode");const g=r.get("basemapTerrain.tilingScheme");if(g&&!g.compatibleWith(y)&&!(p(i)&&h&&g.compatibleWith(h)))throw new e("basemapgalleryitem:tiling-scheme-incompatible","Basemap tiling scheme is incompatible with the view")}export{y as default2DCompatibility,u as default3DCompatibility};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):-1!==e.type.indexOf("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=-1!==e.indexOf("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):-1!==e.type.indexOf("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),s.slices.template.tooltipText=o.rtl?"{category}: %{value.percent.formatNumber('#.0')}":"{category}: {value.percent.formatNumber('#.0')}%",o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=-1!==e.indexOf("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{destroyMaybe as o,isSome as l,isNone as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as u}from"../../core/reactiveUtils.js";import{ReentrantObjectPool as c}from"../../core/ReentrantObjectPool.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as F}from"../../intl/locale.js";import{fetchMessageBundle as v}from"../../intl/messages.js";function C(e){return!!e.inputFields}const I=new t({attributes:{}}),E="esri.widgets.FeatureForm.FeatureFormViewModel",b=s.getLogger(E),V="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",A="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let w=class extends(n(a(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressions=new Map,this._contingentValuesCache=null,this._fieldPool=new c(y),this._fieldGroupPool=new c(_),this._featureClone=I.clone(),this._initialFeature=I.clone(),this._needsArcade=!1,this._inputFieldCache=new Map,this._inputFieldGroupCache=new Map,this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await v("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=u((()=>this.layer),(e=>{"feature"===(null==e?void 0:e.type)&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=u((()=>{var e,t;const{formTemplate:i}=this;if(r(i))return null;const n=null!=(e=i.expressionInfos)?e:[],s=null!=(t=i.elements)?t:[];return[...n.map((e=>e.expression)),...null==s?void 0:s.map((e=>this._getExpressionsFromElementRecursive(e))).flat()]}),(async e=>{if(e.length<1)return;const t=new Set(e),n=new Map;if(l(this.formTemplate)&&l(this.formTemplate.expressionInfos))for(const i of this.formTemplate.expressionInfos)t.delete(i.name),n.set(i.expression,i.name);for(const i of this._compiledExpressions.keys())t.delete(i);if(t.size<1)return;this._needsArcade=!0;const s=await g();this._arcade=s;const{arcadeUtils:o}=s;for(const l of t.values()){var r;o.hasGeometryOperations(l)&&(await o.enableGeometryOperations(),i.remove()),this._setFunctionForExpression(null!=(r=n.get(l))?r:l,l)}this.notifyChange("inputFields")})),n=u((()=>this.formTemplate),(()=>this._compiledExpressions.clear()));this.handles.add([F(e),i,n,t])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._fieldPool.destroy(),this._fieldGroupPool.destroy()}get allInputFields(){return this.inputFields.reduce(((e,t)=>C(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get description(){const{formTemplate:e}=this;return l(e)?e.description:""}set description(e){void 0===e?this._clearOverride("description"):this._override("description",e)}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():I.clone(),this._initialFeature=this._featureClone.clone(),this._inputFieldCache.clear(),this._inputFieldGroupCache.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(r(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,_needsArcade:s,formTemplate:o,messages:r,layer:a,state:u}=this;if("ready"!==u||s&&!e)return[];const c=t.clone(),d=Array.from(n.keys()),p={arcade:e,feature:c,initialFeature:i,layer:a,messages:r},h=l(o)&&o.elements.length>0?this._generateInputFieldsFromElements(o.elements,p):this._generateInputFieldsFromLayerFields(null==a?void 0:a.fields,p);return this._cullInputFieldCache(this._flattenGroups(h).map((e=>e.name)),d),this._releasePreviousInputFields(),h.filter((e=>e.visible))}get joinedContingentValues(){return this._joinContingentValues()}get layer(){var e;return null!=(e=this.feature)&&e.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get title(){const{formTemplate:e}=this;return l(e)?e.title:""}set title(e){void 0===e?this._clearOverride("title"):this._override("title",e)}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){var t;const{_featureClone:i,layer:n}=this,s=!(null==n||!n.getField(e));return null!=(t=i.getAttribute(e))?t:s?null:void 0}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);if(t=""===t?null:t,!s||i.getAttribute(e)===t)return;s.value=t;if(this.get("layer.typeIdField")===s.name&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}n&&!s.valid||(i.setAttribute(e,t),this.notifyChange("inputFields"),this._emitChangeEvent(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),l=[...s,...null!=t&&t.includeIncompleteViolations?o:[]];for(const r of l)for(const e of r.fieldGroup.fields)n.set(e,r);return l}_cullInputFieldCache(e,t){const i=t.filter((t=>!e.includes(t)));for(const n in i)this._inputFieldCache.delete(n)}_flattenGroups(e){return e.flatMap((e=>"groupElement"in e?e.inputFields:e))}_releasePreviousInputFields(){const e=this._get("inputFields");if(e&&!(e.length<1))for(const t of e)"groupElement"in t?this._releaseInputFieldGroup(t):this._releaseInputField(t)}_releaseInputFieldGroup(e){e.inputFields.forEach((e=>this._releaseInputField(e))),this._fieldGroupPool.release(e)}_releaseInputField(e){this._fieldPool.release(e)}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_generateInputFieldsFromElements(e,t){const i=[];for(const n of e)this._isSupportedElement(n)&&i.push("group"===n.type?this._acquireAndInitializeInputFieldGroup(n,t):this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(n.fieldName),fieldElement:n,...t}));return i}_generateInputFieldsFromLayerFields(e,t){return Array.isArray(e)?e.map((e=>this._acquireAndInitializeInputField({field:e,fieldElement:null,...t}))):(b.warn(E,"No attribute fields found."),[])}_acquireAndInitializeInputField(e){var t,i,n,s,o,l;const{arcade:r,feature:a,field:u,fieldElement:c,group:d,initialFeature:p,layer:h,messages:f}=e,m=null!=(t=this._compiledExpressions.get(null==c?void 0:c.requiredExpression))?t:void 0,g=null!=(i=this._compiledExpressions.get(null==c?void 0:c.visibilityExpression))?i:void 0,y=null!=(n=this._compiledExpressions.get(null==c?void 0:c.valueExpression))?n:void 0,_=null!=(s=this._compiledExpressions.get(null==c?void 0:c.editableExpression))?s:void 0,F=u.name,v=null!=(o=null==(l=this._inputFieldCache.get(F))?void 0:l.value)?o:this.getValue(F),C=this._fieldPool.acquire();return this._inputFieldCache.set(F,C),C.set({field:u,fieldElement:c,arcade:r,feature:a,group:d,initialFeature:p,layer:h,messages:f,requiredFunction:m,visibilityFunction:g,editableFunction:_,valueFunction:y,value:v})}_acquireAndInitializeInputFieldGroup(e,t){const i=this._fieldGroupPool.acquire(),n=[];for(const r of e.elements)this._isSupportedElement(r)&&n.push(this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(r.fieldName),fieldElement:r,group:i,...t}));const{arcade:s,feature:o}=t,l=this._compiledExpressions.get(e.visibilityExpression);return i.set({arcade:s,feature:o,groupElement:e,inputFields:n,visibilityFunction:l})}_getExpressionsFromElementRecursive(e){const t=[];if(e.visibilityExpression&&t.push(e.visibilityExpression),"field"===e.type){const i=["requiredExpression","valueExpression","editableExpression"];for(const n of i)e[n]&&t.push(e[n])}if("group"===e.type&&e.elements)for(const i of e.elements)t.push(...this._getExpressionsFromElementRecursive(i));return t}_setFunctionForExpression(e,t){const{_arcade:{arcadeUtils:i},_compiledExpressions:n}=this;n.set(e,i.createFunction(t))}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(b.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(r(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const a of e)for(const e of a.fields)if(t.has(e)){const s=t.get(e),o=a,l=[s.name,o.name].sort().join("|");if(n.has(l))continue;i.push([s,o]),n.add(l),t.set(e,o)}else t.set(e,a);const s=new Set(i.flat()),o=new Set(e);for(const a of s)o.delete(a);const l=new Map,r=new Map;for(const a of new Set(i.flat())){const e=Symbol(a.name);l.set(e,new Set([a])),r.set(a,e)}for(const[a,u]of i){const e=r.get(a),t=r.get(u);if(e===t)continue;const i=l.get(e),n=l.get(t);for(const s of n)i.add(s),r.set(s,e);l.delete(t)}return[[...l.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),a=new Map;for(const l of i.contingencies){const[e]=this._hashContingency(l,s.codedValueFields,!0);a.has(e)?a.get(e).push(l):a.set(e,[l])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(a,i):a.get(i);if(a.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,a.get(j),s.codedValueFields)),!r(o))for(const a of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(a,t,s.rangeFields):this._joinContingencies(a,t);if(r(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}a=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(a,e):a.get(e);if(a.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,a.get(j),s.codedValueFields)),!r(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:l,rightIsNull:r,bothAreNull:a,leftIsAny:u,rightIsAny:c,bothAreAny:d,leftIsRange:p,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(a||d)continue;if(l&&c||r&&u){n.values[s]=new f({objectType:"null"});continue}if(l&&h||r&&p)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{var n,s;const o=t.values[i],l=e.values[i];return"any"===o.objectType||"any"===l.objectType||(null==(n=o.codedValue)?void 0:n.code)===(null==(s=l.codedValue)?void 0:s.code)}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,l=new Set,a=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":l.add(u);break;case"range":a.add(u)}}return{codedValueFields:[...l],rangeFields:[...a]}}_hashContingency(e,t,i=!1){if(t.length<1)return[V,!1];const n=[];let s=!1;for(const l of t){const t=e.values[l];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${l}:.*`)}else if("null"===t.objectType)n.push(`${l}:${A}`);else{var o;n.push(`${l}:${null==(o=t.codedValue)?void 0:o.code}`)}}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([d({readOnly:!0})],w.prototype,"allInputFields",null),e([d()],w.prototype,"_layerFieldsByName",null),e([d({readOnly:!0})],w.prototype,"_inputFieldCache",void 0),e([d({readOnly:!0})],w.prototype,"_inputFieldGroupCache",void 0),e([d()],w.prototype,"contingencyConstraintViolations",void 0),e([d()],w.prototype,"description",null),e([d()],w.prototype,"feature",null),e([d()],w.prototype,"fieldsWithContingentValues",null),e([d({type:h})],w.prototype,"formTemplate",null),e([d({readOnly:!0,dependsOn:["formTemplate","messages","feature","layer.fields","layer.loaded","state"]})],w.prototype,"inputFields",null),e([d()],w.prototype,"joinedContingentValues",null),e([d()],w.prototype,"layer",null),e([d()],w.prototype,"messages",void 0),e([d()],w.prototype,"state",null),e([d()],w.prototype,"strict",void 0),e([d()],w.prototype,"submittable",null),e([d()],w.prototype,"title",null),e([d()],w.prototype,"valid",null),e([d()],w.prototype,"getValues",null),e([d()],w.prototype,"submit",null),w=e([p(E)],w);const x=w;export{x as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import"../../intl.js";import i from"../../core/Evented.js";import{HandleOwnerMixin as n}from"../../core/HandleOwner.js";import s from"../../core/Logger.js";import{destroyMaybe as o,isSome as l,isNone as r}from"../../core/maybe.js";import{EsriPromiseMixin as a}from"../../core/Promise.js";import{watch as u}from"../../core/reactiveUtils.js";import{ReentrantObjectPool as c}from"../../core/ReentrantObjectPool.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import h from"../../form/FormTemplate.js";import f from"../../layers/support/ContingentValue.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{loadArcade as g}from"../../support/arcadeOnDemand.js";import y from"./InputField.js";import _ from"./InputFieldGroup.js";import{onLocaleChange as v}from"../../intl/locale.js";import{fetchMessageBundle as F}from"../../intl/messages.js";function C(e){return!!e.inputFields}const E=new t({attributes:{}}),I="esri.widgets.FeatureForm.FeatureFormViewModel",V=s.getLogger(I),b="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",j="#JSAPI_CONTINGENT_VALUE_ANY_HASH",A="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let w=class extends(n(a(i.EventedAccessor))){constructor(e){super(e),this._arcade=null,this._compiledExpressions=new Map,this._contingentValuesCache=null,this._fieldPool=new c(y,(e=>this.handles.add(u((()=>e.value),(()=>{e.isUsingValueExpression&&this._afterValueChange(e)})),e.id)),(({id:e})=>this.handles.remove(e))),this._fieldGroupPool=new c(_),this._featureClone=E.clone(),this._initialFeature=E.clone(),this._needsArcade=!1,this._inputFieldCache=new Map,this._inputFieldGroupCache=new Map,this.contingencyConstraintViolations=new Map,this.messages=null,this.strict=!1}initialize(){const e=async()=>this.messages=await F("esri/widgets/FeatureForm/t9n/FeatureForm");e();const t=u((()=>this.layer),(e=>{"feature"===(null==e?void 0:e.type)&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(e).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0}),i=u((()=>{var e,t;const{formTemplate:i}=this;if(r(i))return null;const n=null!=(e=i.expressionInfos)?e:[],s=null!=(t=i.elements)?t:[];return[...n.map((e=>e.expression)),...null==s?void 0:s.map((e=>this._getExpressionsFromElementRecursive(e))).flat()]}),(async e=>{if(e.length<1)return;const t=new Set(e),n=new Map;if(l(this.formTemplate)&&l(this.formTemplate.expressionInfos))for(const i of this.formTemplate.expressionInfos)t.delete(i.name),n.set(i.expression,i.name);for(const i of this._compiledExpressions.keys())t.delete(i);if(t.size<1)return;this._needsArcade=!0;const s=await g();this._arcade=s;const{arcadeUtils:o}=s;for(const l of t.values()){var r;o.hasGeometryOperations(l)&&(await o.enableGeometryOperations(),i.remove()),this._setFunctionForExpression(null!=(r=n.get(l))?r:l,l)}this.notifyChange("inputFields")})),n=u((()=>this.formTemplate),(()=>this._compiledExpressions.clear()));this.handles.add([v(e),i,n,t])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._fieldPool.destroy(),this._fieldGroupPool.destroy()}get allInputFields(){return this.inputFields.reduce(((e,t)=>C(t)?[...e,...t.inputFields]:[...e,t]),[])}get _layerFieldsByName(){return new Map(this.layer.fields.map((e=>[e.name,e])))}get description(){const{formTemplate:e}=this;return l(e)?e.description:""}set description(e){void 0===e?this._clearOverride("description"):this._override("description",e)}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():E.clone(),this._initialFeature=this._featureClone.clone(),this._inputFieldCache.clear(),this._inputFieldGroupCache.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(r(this._contingentValuesCache))return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get inputFields(){const{_arcade:e,_featureClone:t,_initialFeature:i,_inputFieldCache:n,_needsArcade:s,formTemplate:o,messages:r,layer:a,state:u}=this;if("ready"!==u||s&&!e)return[];const c=t.clone(),d=Array.from(n.keys()),p={arcade:e,feature:c,initialFeature:i,layer:a,messages:r},h=l(o)&&o.elements.length>0?this._generateInputFieldsFromElements(o.elements,p):this._generateInputFieldsFromLayerFields(null==a?void 0:a.fields,p);return this._cullInputFieldCache(this._flattenGroups(h).map((e=>e.name)),d),this._releasePreviousInputFields(),h.filter((e=>e.visible))}get joinedContingentValues(){return this._joinContingentValues()}get layer(){var e;return null!=(e=this.feature)&&e.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){e?this._override("layer",e):this._clearOverride("layer")}get state(){return this.messages&&this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allInputFields.filter((e=>!e.valid)).every((({submittable:e})=>e))}get title(){const{formTemplate:e}=this;return l(e)?e.title:""}set title(e){void 0===e?this._clearOverride("title"):this._override("title",e)}get valid(){const e=this.allInputFields;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allInputFields.find((t=>t.name===e))}getValue(e){var t;const{_featureClone:i,layer:n}=this,s=!(null==n||!n.getField(e));return null!=(t=i.getAttribute(e))?t:s?null:void 0}setValue(e,t){const{_featureClone:i,strict:n}=this,s=this.findField(e);t=""===t?null:t,s&&i.getAttribute(e)!==t&&(s.value=t,n&&!s.valid||this._afterValueChange(s))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allInputFields,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),i=e.filter((e=>!e.valid)).map((({name:e})=>e)),n=this.getValues();if(this.validateContingencyConstraints(n,{includeIncompleteViolations:!0}).length>0)for(const[s,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(s),i.push(s));this.emit("submit",{valid:[...t],invalid:i,values:n})}validateContingencyConstraints(e,t){const{_contingentValuesCache:i}=this,n=new Map;if(this.contingencyConstraintViolations=n,r(i))return[];const{invalid:s,incomplete:o}=i.validateContingencyConstraints(e),l=[...s,...null!=t&&t.includeIncompleteViolations?o:[]];for(const r of l)for(const e of r.fieldGroup.fields)n.set(e,r);return l}_cullInputFieldCache(e,t){const i=t.filter((t=>!e.includes(t)));for(const n in i)this._inputFieldCache.delete(n)}_flattenGroups(e){return e.flatMap((e=>"groupElement"in e?e.inputFields:e))}_releasePreviousInputFields(){const e=this._get("inputFields");if(e&&!(e.length<1))for(const t of e)"groupElement"in t?this._releaseInputFieldGroup(t):this._releaseInputField(t)}_releaseInputFieldGroup(e){e.inputFields.forEach((e=>this._releaseInputField(e))),this._fieldGroupPool.release(e)}_releaseInputField(e){this._fieldPool.release(e)}_emitChangeEvent({name:e,valid:t,value:i}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:i,valid:t})}_generateInputFieldsFromElements(e,t){const i=[];for(const n of e)this._isSupportedElement(n)&&i.push("group"===n.type?this._acquireAndInitializeInputFieldGroup(n,t):this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(n.fieldName),fieldElement:n,...t}));return i}_generateInputFieldsFromLayerFields(e,t){return Array.isArray(e)?e.map((e=>this._acquireAndInitializeInputField({field:e,fieldElement:null,...t}))):(V.warn(I,"No attribute fields found."),[])}_acquireAndInitializeInputField(e){var t,i,n,s,o,l;const{arcade:r,feature:a,field:u,fieldElement:c,group:d,initialFeature:p,layer:h,messages:f}=e,m=null!=(t=this._compiledExpressions.get(null==c?void 0:c.requiredExpression))?t:void 0,g=null!=(i=this._compiledExpressions.get(null==c?void 0:c.visibilityExpression))?i:void 0,y=null!=(n=this._compiledExpressions.get(null==c?void 0:c.valueExpression))?n:void 0,_=null!=(s=this._compiledExpressions.get(null==c?void 0:c.editableExpression))?s:void 0,v=u.name,F=null!=(o=null==(l=this._inputFieldCache.get(v))?void 0:l.value)?o:this.getValue(v),C=this._fieldPool.acquire();return this._inputFieldCache.set(v,C),C.set({field:u,fieldElement:c,arcade:r,feature:a,group:d,initialFeature:p,layer:h,messages:f,requiredFunction:m,visibilityFunction:g,editableFunction:_,valueFunction:y,value:F})}_acquireAndInitializeInputFieldGroup(e,t){const i=this._fieldGroupPool.acquire(),n=[];for(const r of e.elements)this._isSupportedElement(r)&&n.push(this._acquireAndInitializeInputField({field:this._layerFieldsByName.get(r.fieldName),fieldElement:r,group:i,...t}));const{arcade:s,feature:o}=t,l=this._compiledExpressions.get(e.visibilityExpression);return i.set({arcade:s,feature:o,groupElement:e,inputFields:n,visibilityFunction:l})}_afterValueChange(e){const{name:t,value:i}=e;if(this.get("layer.typeIdField")===e.name&&"types"in this.layer){const e=new Set;this.layer.types.forEach((t=>Object.keys(t.domains).forEach((t=>e.add(t))))),e.forEach((e=>{const t=this.findField(e);t&&t.notifyChange("domain")}))}this._featureClone.setAttribute(t,i),this.notifyChange("inputFields"),this._emitChangeEvent(e)}_getExpressionsFromElementRecursive(e){const t=[];if(e.visibilityExpression&&t.push(e.visibilityExpression),"field"===e.type){const i=["requiredExpression","valueExpression","editableExpression"];for(const n of i)e[n]&&t.push(e[n])}if("group"===e.type&&e.elements)for(const i of e.elements)t.push(...this._getExpressionsFromElementRecursive(i));return t}_setFunctionForExpression(e,t){const{_arcade:{arcadeUtils:i},_compiledExpressions:n}=this;n.set(e,i.createFunction(t))}_isSupportedElement(e){return"field"===e.type||"group"===e.type||(V.warn("form-info::unsupported-element-type","Only element types 'field' and 'group' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}_joinContingentValues(){const e=this._contingentValuesCache;if(r(e))return[];const t="typeIdField"in this.layer?this.layer.typeIdField:null,i=t?this.getValue(t):null,n=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:s}=r,o=[];for(const n of e)n.isRetired||l(n.subtype)&&n.subtype.code!==i||o.push({values:n.values});o.length>0&&n.push({name:s,fields:t,contingencies:o})}const[s,o]=this._generateJoinPlan(n);return[...s.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,i=[],n=new Set;for(const a of e)for(const e of a.fields)if(t.has(e)){const s=t.get(e),o=a,l=[s.name,o.name].sort().join("|");if(n.has(l))continue;i.push([s,o]),n.add(l),t.set(e,o)}else t.set(e,a);const s=new Set(i.flat()),o=new Set(e);for(const a of s)o.delete(a);const l=new Map,r=new Map;for(const a of new Set(i.flat())){const e=Symbol(a.name);l.set(e,new Set([a])),r.set(a,e)}for(const[a,u]of i){const e=r.get(a),t=r.get(u);if(e===t)continue;const i=l.get(e),n=l.get(t);for(const s of n)i.add(s),r.set(s,e);l.delete(t)}return[[...l.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),i=t.shift();let n=t.shift(),s=this._generateJoinKey(i.fields,n.fields),o=new Set([...i.fields,...n.fields]),a=new Map;for(const l of i.contingencies){const[e]=this._hashContingency(l,s.codedValueFields,!0);a.has(e)?a.get(e).push(l):a.set(e,[l])}for(;t.length>0;){const e=new Map,i=t.shift(),l=this._generateJoinKey(o,i.fields);for(const t of n.contingencies){const[i,n]=this._hashContingency(t,s.codedValueFields),o=n?this._findMatchingContingenciesWithAnyHashMask(a,i):a.get(i);if(a.has(j)&&o.push(...this._findMatchingContingenciesContainingAny(t,a.get(j),s.codedValueFields)),!r(o))for(const a of o){const i=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(a,t,s.rangeFields):this._joinContingencies(a,t);if(r(i))break;const[n]=this._hashContingency(i,l.codedValueFields,!0);e.has(n)?e.get(n).push(i):e.set(n,[i])}}a=e,n=i,s=l,o=new Set([...o,...n.fields])}const u=[];for(const c of n.contingencies){const[e,t]=this._hashContingency(c,s.codedValueFields),i=t?this._findMatchingContingenciesWithAnyHashMask(a,e):a.get(e);if(a.has(j)&&i.push(...this._findMatchingContingenciesContainingAny(c,a.get(j),s.codedValueFields)),!r(i))for(const n of i){const e=s.rangeFields.length>0?this._joinContingenciesWithRangeDomains(n,c,s.rangeFields):this._joinContingencies(n,c);l(e)&&u.push(e)}}return u}_joinContingencies(e,t){const i={values:{...e.values,...t.values}};for(const[n,s]of Object.entries(i.values))"any"===s.objectType&&l(e.values[n])&&(i.values[n]=e.values[n]);return i}_joinContingenciesWithRangeDomains(e,t,i){const n=this._joinContingencies(e,t);for(const s of i){const i=e.values[s],o=t.values[s],{leftIsNull:l,rightIsNull:r,bothAreNull:a,leftIsAny:u,rightIsAny:c,bothAreAny:d,leftIsRange:p,rightIsRange:h}=this._compareObjectTypes(i.objectType,o.objectType);if(a||d)continue;if(l&&c||r&&u){n.values[s]=new f({objectType:"null"});continue}if(l&&h||r&&p)return null;u?(i.minValue=-1/0,i.maxValue=1/0):c&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(i.minValue,o.minValue),g=Math.min(i.maxValue,o.maxValue);if(m>g)return null;n.values[s]=new f({objectType:"range",minValue:m,maxValue:g})}return n}_findMatchingContingenciesContainingAny(e,t,i){return t.filter((t=>i.every((i=>{var n,s;const o=t.values[i],l=e.values[i];return"any"===o.objectType||"any"===l.objectType||(null==(n=o.codedValue)?void 0:n.code)===(null==(s=l.codedValue)?void 0:s.code)}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const i=RegExp(`${t}$`),n=[];for(const[s,o]of e){if(s===j)break;i.test(s)&&n.push(...o)}return n}_generateJoinKey(e,t){const i=Array.isArray(e)?new Set(e):e,n=Array.isArray(t)?new Set(t):t,s=i.size<n.size?i:n,o=s===i?n:i,l=new Set,a=new Set;for(const u of s)if(o.has(u)){const e=this.layer.getFieldDomain(u,{feature:this.feature});if(r(e))continue;switch(e.type){case"coded-value":l.add(u);break;case"range":a.add(u)}}return{codedValueFields:[...l],rangeFields:[...a]}}_hashContingency(e,t,i=!1){if(t.length<1)return[b,!1];const n=[];let s=!1;for(const l of t){const t=e.values[l];if("any"===t.objectType){if(i)return[j,!0];s=!0,n.push(`${l}:.*`)}else if("null"===t.objectType)n.push(`${l}:${A}`);else{var o;n.push(`${l}:${null==(o=t.codedValue)?void 0:o.code}`)}}return[n.sort().join("&"),s]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};e([d({readOnly:!0})],w.prototype,"allInputFields",null),e([d()],w.prototype,"_layerFieldsByName",null),e([d({readOnly:!0})],w.prototype,"_inputFieldCache",void 0),e([d({readOnly:!0})],w.prototype,"_inputFieldGroupCache",void 0),e([d()],w.prototype,"contingencyConstraintViolations",void 0),e([d()],w.prototype,"description",null),e([d()],w.prototype,"feature",null),e([d()],w.prototype,"fieldsWithContingentValues",null),e([d({type:h})],w.prototype,"formTemplate",null),e([d({readOnly:!0,dependsOn:["formTemplate","messages","feature","layer.fields","layer.loaded","state"]})],w.prototype,"inputFields",null),e([d()],w.prototype,"joinedContingentValues",null),e([d()],w.prototype,"layer",null),e([d()],w.prototype,"messages",void 0),e([d()],w.prototype,"state",null),e([d()],w.prototype,"strict",void 0),e([d()],w.prototype,"submittable",null),e([d()],w.prototype,"title",null),e([d()],w.prototype,"valid",null),e([d()],w.prototype,"getValues",null),e([d()],w.prototype,"submit",null),w=e([p(I)],w);const x=w;export{x 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.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import u from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as d,DomainValidationError as p,getDomainRange as c}from"../../layers/support/domainUtils.js";import{isNumericField as h,isStringField as m,isDateField as y,TypeValidationError as v,validateFieldValue as f,getFeatureEditFields as g,getFeatureGeometryFields as E,NumericRangeValidationError as b,getFieldRange as _}from"../../layers/support/fieldUtils.js";import{substitute as x}from"../../intl/substitute.js";var F,V;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(F||(F={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(V||(V={}));const O={type:"number"},U={type:"number",intlOptions:{notation:"scientific"}},T={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};let A=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new u({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===F.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&j(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===F.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&j(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return h(e)?F.Number:m(e)?F.Text:y(e)?F.Date:F.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&m(t)||"number"===i&&h(t))return!0}return!!("range"===(null==e?void 0:e.type)&&h(t)||y(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?V.TOO_SHORT:e?null!==s||r?d(e,s):null:a?v.INVALID_TYPE:f(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return g(this.layer).indexOf(this.name)>-1}_isGeometryField(){return E(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===p.VALUE_OUT_OF_RANGE||s===b.OUT_OF_RANGE){const l=c(e)||_(t);return x(i.validationErrors.outsideRange,l,{format:{max:"date"===o?T:l.isInteger?O:U,min:"date"===o?T:l.isInteger?O:U}})}return s===p.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===v.INVALID_TYPE?i.validationErrors.invalidType:s===V.TOO_SHORT?x(i.validationErrors.tooShort,{min:l}):null}};function j(e){return!!e&&"maxLength"in e}e([s()],A.prototype,"_storedValue",void 0),e([s()],A.prototype,"_configAllowsEdits",null),e([s()],A.prototype,"_layerFieldAllowsEdits",null),e([s()],A.prototype,"arcade",void 0),e([s()],A.prototype,"editableFunction",void 0),e([s()],A.prototype,"requiredFunction",void 0),e([s()],A.prototype,"valueFunction",void 0),e([s()],A.prototype,"isUsingValueExpression",null),e([s()],A.prototype,"visibilityFunction",void 0),e([s()],A.prototype,"evaluatedEditableExpression",null),e([s()],A.prototype,"evaluatedRequiredExpression",null),e([s()],A.prototype,"evaluatedVisibilityExpression",null),e([s()],A.prototype,"evaluatedValueExpression",null),e([s()],A.prototype,"feature",void 0),e([s()],A.prototype,"field",void 0),e([s()],A.prototype,"fieldElement",void 0),e([s()],A.prototype,"initialFeature",null),e([s()],A.prototype,"layer",void 0),e([s({aliasOf:"fieldElement.description"})],A.prototype,"description",void 0),e([s()],A.prototype,"domain",null),e([s()],A.prototype,"editable",null),e([s({aliasOf:"fieldElement.input.type"})],A.prototype,"inputType",void 0),e([s({readOnly:!0})],A.prototype,"error",void 0),e([s({dependsOn:["error","messages","value"]})],A.prototype,"errorMessage",null),e([s()],A.prototype,"group",void 0),e([s({aliasOf:"fieldElement.hint"})],A.prototype,"hint",void 0),e([s()],A.prototype,"includeTime",null),e([s()],A.prototype,"label",null),e([s()],A.prototype,"maxLength",null),e([s()],A.prototype,"minLength",null),e([s()],A.prototype,"messages",void 0),e([s({aliasOf:"field.name"})],A.prototype,"name",void 0),e([s()],A.prototype,"required",null),e([s()],A.prototype,"submittable",null),e([s()],A.prototype,"type",null),e([s()],A.prototype,"valid",null),e([s({value:null})],A.prototype,"value",null),e([s()],A.prototype,"visible",null),A=e([a("esri.widgets.FeatureForm.InputField")],A);const D=A;export{D as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import t from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{isSome as l,isNone as r,get as n}from"../../core/maybe.js";import{watch as o}from"../../core/reactiveUtils.js";import{generateUID as s}from"../../core/uid.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import d from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{validateDomainValue as p,DomainValidationError as c,getDomainRange as h}from"../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as y,isDateField as v,TypeValidationError as f,validateFieldValue as g,getFeatureEditFields as E,getFeatureGeometryFields as b,NumericRangeValidationError as _,getFieldRange as x}from"../../layers/support/fieldUtils.js";import{substitute as F}from"../../intl/substitute.js";var V,O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(V||(V={})),function(e){e.TOO_SHORT="length-validation-error::too-short"}(O||(O={}));const U={type:"number"},T={type:"number",intlOptions:{notation:"scientific"}},j={type:"date",intlOptions:{day:"2-digit",month:"2-digit",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric"}};let A=class extends(i(t)){constructor(e){super(e),this._storedValue=null,this.arcade=null,this.editableFunction=null,this.id=s().toString(),this.requiredFunction=null,this.valueFunction=null,this.visibilityFunction=null,this.feature=null,this.field=null,this.fieldElement=null,this.layer=null,this.description=null,this.inputType=null,this.error=null,this.group=null,this.hint=null,this.messages=null,this.name=null}initialize(){this.handles.add(o((()=>this.value),((e,t)=>{if(e!==t){const{feature:e,name:t,value:i}=this;e.setAttribute(t,i)}})))}get _configAllowsEdits(){var e,t,i;const{fieldElement:r,layer:n,name:o}=this;if(l(r))return!1!==r.editable;const s="subtype-group"!==(null==n?void 0:n.type)?null==n||null==(e=n.popupTemplate)||null==(t=e.fieldInfos)?void 0:t.find((({fieldName:e})=>e===o)):null;return null==(i=null==s?void 0:s.isEditable)||i}get _layerFieldAllowsEdits(){const{field:e,layer:t}=this;return(null==t?void 0:t.capabilities.operations.supportsEditing)&&(null==e?void 0:e.editable)}get isUsingValueExpression(){return this._shouldUseValueExpression()}get evaluatedEditableExpression(){const{editableFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedRequiredExpression(){const{requiredFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedVisibilityExpression(){const{visibilityFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}get evaluatedValueExpression(){const{valueFunction:e}=this;if(r(e))return null;const{arcade:t}=this;return t.arcadeUtils.executeFunction(e,t.arcadeUtils.createExecContext(this.feature))}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get domain(){var e;const{typeIdField:t}=this.layer,i=t===this.name,r=null==(e=this.field)?void 0:e.domain;if(i&&!r){const{layer:e}=this,t="subtype-group"===e.type?e.sublayers.map((({subtypeCode:e,title:t})=>({id:e,name:t}))):e.types.map((({id:e,name:t})=>({code:e,name:t})));return new d({name:"__internal-type-based-coded-value-domain__",codedValues:t})}const{feature:o}=this,s=t&&this.layer.getFieldDomain(this.name,{feature:o})||r,a=n(this.fieldElement,"domain");return l(a)&&this._isDomainCompatible(a)?a:s}get editable(){var e;return!!this._layerFieldAllowsEdits&&(null!=(e=this.evaluatedEditableExpression)?e:this._configAllowsEdits)}get errorMessage(){return this._toErrorMessage()}get includeTime(){var e;const{fieldElement:t}=this,i=l(t)&&"datetime-picker"===(null==(e=t.input)?void 0:e.type)?t.input.includeTime:void 0;return void 0===i||i}get label(){return l(this.fieldElement)&&this.fieldElement.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.maxLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:r}get minLength(){const e=-1;if(this.type===V.Date)return e;const{field:t,fieldElement:i}=this,r=null==t?void 0:t.length,n=l(i)&&D(i.input)?i.input.minLength:NaN;return!isNaN(n)&&n>=e&&(r===e||n<=r)?n:e}get required(){var e,t;return!!this.editable&&(!1===(null==(e=this.field)?void 0:e.nullable)||null!=(t=this.evaluatedRequiredExpression)&&t)}get submittable(){return!!this.valid||this.initialFeature.getAttribute(this.field.name)===this.value}get type(){const{field:e}=this;return m(e)?V.Number:y(e)?V.Text:v(e)?V.Date:V.Unsupported}get valid(){const e=this._validate();return this._set("error",e),null===e}get value(){return this._shouldUseValueExpression()?this.evaluatedValueExpression:this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditorField()&&(l(this.fieldElement)?null==(e=this.evaluatedVisibilityExpression)||e:this._isVisibleByDefault());var e}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===(null==e?void 0:e.type)){const i=typeof e.codedValues[0].code;if("string"===i&&y(t)||"number"===i&&m(t))return!0}return!!("range"===(null==e?void 0:e.type)&&m(t)||v(t))}_validate(){const{domain:e,field:t,initialFeature:i,minLength:l,required:r,type:n,valid:o,value:s}=this,a=r&&null===s,u=void 0!==o;return!a&&i.getAttribute(t.name)===s&&u?null:"text"===n&&l>-1&&"string"==typeof s&&s.length<l?O.TOO_SHORT:e?null!==s||r?p(e,s):null:a?f.INVALID_TYPE:g(t,s)}_isVisibleByDefault(){var e;const t=null==(e=this.field)?void 0:e.type;return"oid"!==t&&"global-id"!==t&&!this._isGeometryField()}_isEditorField(){return E(this.layer).indexOf(this.name)>-1}_isGeometryField(){return b(this.layer).indexOf(this.name)>-1}_shouldUseValueExpression(){return this._layerFieldAllowsEdits&&!this._configAllowsEdits&&l(this.valueFunction)}_toErrorMessage(){const{domain:e,field:t,messages:i,minLength:l,value:r,required:n,type:o}=this,s=this.error;if(n&&null===r)return i.validationErrors.cannotBeNull;if(s===c.VALUE_OUT_OF_RANGE||s===_.OUT_OF_RANGE){const l=h(e)||x(t);return F(i.validationErrors.outsideRange,l,{format:{max:"date"===o?j:l.isInteger?U:T,min:"date"===o?j:l.isInteger?U:T}})}return s===c.INVALID_CODED_VALUE?i.validationErrors.invalidCodedValue:s===f.INVALID_TYPE?i.validationErrors.invalidType:s===O.TOO_SHORT?F(i.validationErrors.tooShort,{min:l}):null}};function D(e){return!!e&&"maxLength"in e}e([a()],A.prototype,"_storedValue",void 0),e([a()],A.prototype,"_configAllowsEdits",null),e([a()],A.prototype,"_layerFieldAllowsEdits",null),e([a()],A.prototype,"arcade",void 0),e([a()],A.prototype,"editableFunction",void 0),e([a()],A.prototype,"requiredFunction",void 0),e([a()],A.prototype,"valueFunction",void 0),e([a()],A.prototype,"isUsingValueExpression",null),e([a()],A.prototype,"visibilityFunction",void 0),e([a()],A.prototype,"evaluatedEditableExpression",null),e([a()],A.prototype,"evaluatedRequiredExpression",null),e([a()],A.prototype,"evaluatedVisibilityExpression",null),e([a()],A.prototype,"evaluatedValueExpression",null),e([a()],A.prototype,"feature",void 0),e([a()],A.prototype,"field",void 0),e([a()],A.prototype,"fieldElement",void 0),e([a()],A.prototype,"initialFeature",null),e([a()],A.prototype,"layer",void 0),e([a({aliasOf:"fieldElement.description"})],A.prototype,"description",void 0),e([a()],A.prototype,"domain",null),e([a()],A.prototype,"editable",null),e([a({aliasOf:"fieldElement.input.type"})],A.prototype,"inputType",void 0),e([a({readOnly:!0})],A.prototype,"error",void 0),e([a({dependsOn:["error","messages","value"]})],A.prototype,"errorMessage",null),e([a()],A.prototype,"group",void 0),e([a({aliasOf:"fieldElement.hint"})],A.prototype,"hint",void 0),e([a()],A.prototype,"includeTime",null),e([a()],A.prototype,"label",null),e([a()],A.prototype,"maxLength",null),e([a()],A.prototype,"minLength",null),e([a()],A.prototype,"messages",void 0),e([a({aliasOf:"field.name"})],A.prototype,"name",void 0),e([a()],A.prototype,"required",null),e([a()],A.prototype,"submittable",null),e([a()],A.prototype,"type",null),e([a()],A.prototype,"valid",null),e([a({value:null})],A.prototype,"value",null),e([a()],A.prototype,"visible",null),A=e([u("esri.widgets.FeatureForm.InputField")],A);const N=A;export{N as default};