@arcgis/core 4.28.2 → 4.28.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02e86a792dbe2fdec974.js +1 -0
- package/assets/esri/core/workers/chunks/{5386b166f2e5dc0d9143.js → 12797aa1d6a2b49abb3f.js} +1 -1
- package/assets/esri/core/workers/chunks/15852a47129b9e0d04c6.js +1 -0
- package/assets/esri/core/workers/chunks/1687431f7b233d950195.js +1 -0
- package/assets/esri/core/workers/chunks/{a1e16c33f1843dbdce26.js → 175bbe8a048f17dd482b.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0119dff8771e749436a.js → 30d3b31df52d40e5b2e6.js} +1 -1
- package/assets/esri/core/workers/chunks/{768271a12dc7e1781447.js → 32fbd4355a4a649623a7.js} +1 -1
- package/assets/esri/core/workers/chunks/3dbc399eedd347b0fbbb.js +1 -0
- package/assets/esri/core/workers/chunks/{6bc1f6f8a2408fa4bb6a.js → 423672fe765083e1a0ec.js} +1 -1
- package/assets/esri/core/workers/chunks/{18e0c5bfeb1aa7213dfa.js → 4363f2cc3909c9258064.js} +1 -1
- package/assets/esri/core/workers/chunks/{d5fec54e98c8622349a4.js → 46ddc52fe9cdd573a614.js} +1 -1
- package/assets/esri/core/workers/chunks/4747741429e8ff7112bb.js +1 -0
- package/assets/esri/core/workers/chunks/49d958631bcd93f6333a.js +1 -0
- package/assets/esri/core/workers/chunks/4ae8308e5b9c7772a11f.js +1 -0
- package/assets/esri/core/workers/chunks/{da124ccd18d2745195fe.js → 4bd342f13002888b6467.js} +1 -1
- package/assets/esri/core/workers/chunks/{7756ed853b4ba54cd081.js → 5247c00088303da7ef3b.js} +1 -1
- package/assets/esri/core/workers/chunks/534726130ef1698ec89e.js +1 -0
- package/assets/esri/core/workers/chunks/551bc697e3e17983c2bc.js +1 -0
- package/assets/esri/core/workers/chunks/{65d8135c89ffdd17a3c1.js → 59d3f4c0d1a43180aff3.js} +1 -1
- package/assets/esri/core/workers/chunks/{2d92df1e3ba4f05e0510.js → 633b34a5817f1f719e22.js} +1 -1
- package/assets/esri/core/workers/chunks/{c7bd63103f101c09b1ea.js → 6996537249869c41e736.js} +1 -1
- package/assets/esri/core/workers/chunks/{41778f8c49febe1f9404.js → 6fa0cccd4f3e1fa71421.js} +1 -1
- package/assets/esri/core/workers/chunks/{78e49a70193e5adea17c.js → 77f557359a5033d7e429.js} +1 -1
- package/assets/esri/core/workers/chunks/{6334a8a7b671d4042108.js → 7beae29abdfae23b15cc.js} +1 -1
- package/assets/esri/core/workers/chunks/7cc56b132c46c5922dac.js +1 -0
- package/assets/esri/core/workers/chunks/80831e90fe1a52f8f982.js +1 -0
- package/assets/esri/core/workers/chunks/{ea9ae9d2aef01af90896.js → 80d9bb9f247ecdfa266f.js} +1 -1
- package/assets/esri/core/workers/chunks/846e5e51dc278bc3f80f.js +1 -0
- package/assets/esri/core/workers/chunks/{f73563b23fd8dc6cf2fe.js → 86df7357a2bac73c0ef4.js} +1 -1
- package/assets/esri/core/workers/chunks/8b541cbf82a5ba0317ee.js +1 -0
- package/assets/esri/core/workers/chunks/{08a98e85e86ce560d005.js → 8bd621693692050d76aa.js} +1 -1
- package/assets/esri/core/workers/chunks/{630b31a205d9db7147d0.js → 8cdece03397d01767593.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9a726f3bbad6fd4d65a.js → 8e91be2e38010391e351.js} +1 -1
- package/assets/esri/core/workers/chunks/{cbddfcf57f72428a6992.js → 90f96a2ddfb25d851d4d.js} +1 -1
- package/assets/esri/core/workers/chunks/91a3181071874525ed44.js +1 -0
- package/assets/esri/core/workers/chunks/{2304b7456ced997904f6.js → 97fd7b82eec26449977e.js} +1 -1
- package/assets/esri/core/workers/chunks/{b7c81a5bbcdd94b8a7f6.js → 9979ff59a144fe1df80b.js} +1 -1
- package/assets/esri/core/workers/chunks/{0422c5160491fbcf01dc.js → 9d97a20f69047d0c47cc.js} +1 -1
- package/assets/esri/core/workers/chunks/9f0e8dd5c9bacfc0f03c.js +1 -0
- package/assets/esri/core/workers/chunks/{a8e4726c1db23324eb54.js → 9fc1206ad378f0829e0a.js} +1 -1
- package/assets/esri/core/workers/chunks/{09e8babe75407c2e64c4.js → a351ab5082772b267895.js} +1 -1
- package/assets/esri/core/workers/chunks/{43575b9acf9819f195f9.js → a3bbf5da4f7830d2a2a1.js} +1 -1
- package/assets/esri/core/workers/chunks/{b03eaba5fa75d6ef834a.js → a47f74fc959b11f029a5.js} +1 -1
- package/assets/esri/core/workers/chunks/{cb4b17f5cf96a9e36781.js → a8cf23c3a55c1834178c.js} +1 -1
- package/assets/esri/core/workers/chunks/{dd55151bfac60b0deaac.js → ac4636e82a103e2c27ca.js} +1 -1
- package/assets/esri/core/workers/chunks/ae7ba94af6d4fd97dd8b.js +1 -0
- package/assets/esri/core/workers/chunks/{4adf3a8c6b49c381a633.js → b0653f63745e756f55fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{e06cd10b6f8f363b5131.js → bdc751a752a7ff1387de.js} +1 -1
- package/assets/esri/core/workers/chunks/{70aa04b09143b7dd2ecb.js → c2199fb8f7a54a0ef18a.js} +1 -1
- package/assets/esri/core/workers/chunks/c3f462d11ed570482e7a.js +1 -0
- package/assets/esri/core/workers/chunks/{830d99e6c58a52a58973.js → c8cb5fe1d23145c4842b.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f87f22e00e3218661c6.js → ce53413dd3e2062e8378.js} +1 -1
- package/assets/esri/core/workers/chunks/de30ff1fcb6079178958.js +1 -0
- package/assets/esri/core/workers/chunks/e12090768e945091cc5d.js +1 -0
- package/assets/esri/core/workers/chunks/e3950975030412ff6e20.js +1 -0
- package/assets/esri/core/workers/chunks/e8b7d1c586aff229484c.js +1 -0
- package/assets/esri/core/workers/chunks/{710a6268de62003af825.js → e8d1f91dc97b42d0c4f6.js} +1 -1
- package/assets/esri/core/workers/chunks/{6747503826bfc94bc6c0.js → eb5213ffb83d83a4dd05.js} +1 -1
- package/assets/esri/core/workers/chunks/{020825b9c12f2b6386a7.js → f037e4f9877ea08ced9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{abcfe3bda6f40318b092.js → f7ccc6c681fc9218555c.js} +1 -1
- package/assets/esri/core/workers/chunks/{eea0fb90cd5cc80de388.js → fa750885bb27bbb03e7d.js} +1 -1
- package/assets/esri/core/workers/chunks/{e67c4b7ad06d8404895a.js → fab4ee57b7c5376c9ccd.js} +1 -1
- package/interfaces.d.ts +4 -4
- package/kernel.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/support/RangeDomain.js +1 -1
- package/layers/support/domainUtils.js +1 -1
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/labelFormatUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/featureFormUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/support/dataUtils.js +5 -0
- package/widgets/support/dateUtils.js +1 -1
- package/assets/esri/core/workers/chunks/02d235849ba93541d7ad.js +0 -1
- package/assets/esri/core/workers/chunks/0a3da4b73beeaacd4667.js +0 -1
- package/assets/esri/core/workers/chunks/10dc578a90e1194c8720.js +0 -1
- package/assets/esri/core/workers/chunks/1eb5468c7cf653338d53.js +0 -1
- package/assets/esri/core/workers/chunks/1f30ea1a598ddd2e5df3.js +0 -1
- package/assets/esri/core/workers/chunks/366cf9bba6989342e447.js +0 -1
- package/assets/esri/core/workers/chunks/43f7d9366d06d69e7c50.js +0 -1
- package/assets/esri/core/workers/chunks/4672504d6fe649da19f2.js +0 -1
- package/assets/esri/core/workers/chunks/56a61a8bff08ae273de4.js +0 -1
- package/assets/esri/core/workers/chunks/580e7d3cbf6797a50ded.js +0 -1
- package/assets/esri/core/workers/chunks/6046be598e8c673eeb1f.js +0 -1
- package/assets/esri/core/workers/chunks/69c1c850af7ee33258e0.js +0 -1
- package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +0 -1
- package/assets/esri/core/workers/chunks/a160576f21ada91995ac.js +0 -1
- package/assets/esri/core/workers/chunks/a50ec5b647a160199cb2.js +0 -1
- package/assets/esri/core/workers/chunks/b138196d304883efd5f6.js +0 -1
- package/assets/esri/core/workers/chunks/b3f5e97b47e896c6008a.js +0 -1
- package/assets/esri/core/workers/chunks/c447f4bf0e5f012f8f9b.js +0 -1
- package/assets/esri/core/workers/chunks/c87e9280681c20d042b5.js +0 -1
- package/assets/esri/core/workers/chunks/cc86c8c88124d916e1b3.js +0 -1
- package/assets/esri/core/workers/chunks/d878bb6409df183ea0ce.js +0 -1
- package/assets/esri/core/workers/chunks/ef757269fb3fe0e74ef8.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import has from"../../../../core/has.js";import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class P{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class y{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=F}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new P;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new P;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new P(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,T);else{const t=D,o=U,a=Q;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new z,o=new z,r=this._imModificationUncategorized;r.clear();const a=new Set;let l=0;const d=(d,h,u)=>{const c=O(d,this._pageSize);if(a.add(c),null==h){let e=this._entryPriority(d);return e===1/0&&(e=this._entryPriority(u)),x.set(c,Math.max(e,x.get(c)||0)),this._loadingPages.has(c)||this._failedPages.has(c)||(this._missingPagesAndNodes.push(c),++l),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=h.node;if(this._updateNodeFeatureEstimate(g,o),null==g){const e=this._entryPriority(d);return this._loadingNodes.has(d)||this._failedNodes.has(d)||(this._missingPagesAndNodes.push(d),x.set(d,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=this._getPage(d);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<h.childCount;e++){const t=f.children[h.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(g.failed||g.resources.isEmpty)return void(s&&h.childCount>0&&this._isSelected(g)&&(s=!1));if(this._isLoaded(d)){if(n.known+=g.memory,++n.knownNodes,this._isSelected(g)?h.childCount>0&&(s=!1):(n.unremoved+=g.memory,s=!1),this._needsUpdate(g)){const e=this._entryPriority(d);x.set(d,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(d)}return}if(g.memory&&(n.known+=g.memory,++n.knownNodes),!this._isSelected(g))return void(this._isReloading(d)&&this._updates.remove.push(d));if(h.childCount>0&&(s=!1),g.memory?(n.missing+=g.memory,n.known+=g.memory,++n.knownNodes):++n.missingNodes,e.includes(g.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(d)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==g.index)));if(!t.done&&this._enable(g))return void t.madeProgress();const m=this._entryPriority(d);x.set(d,m),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,m),this._updates.add.push(d),this.layerHasModifications&&i&&null!=g&&g.imModificationImpact===_.NotChecked&&r.push(d)};this.traverseVisible(d),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear()),this._removeUnusedNodePages(a,l);const h=this._updates.add;h.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),h.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new z;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_removeUnusedNodePages(e,t){if(!this._useNodePages)return;const i=this._nodePages,s=e.size,n=i.size+this._loadingPages.size+t;if(n>$&&n>s){const t=new Array;for(const[s,n]of i)0!==n.numNodesWithLoadedChildren||e.has(s)||t.push([n.lastTraversed,s]);t.sort(((e,t)=>e[0]-t[0])).some((e=>{const t=e[1];return this._deleteNodePage(t),i.size<=$}))}}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class z{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function F(e){return Math.sqrt(e*(4/Math.PI))}const T=a(),D=a(),U=a(),Q=a(),$=has("esri-mobile")?100:300;export{y as I3SIndex,k as selectErrorMetric};
|
|
5
|
+
import e from"../../../../core/PooledArray.js";import{isAbortError as t}from"../../../../core/promiseUtils.js";import{l as i}from"../../../../chunks/vec3.js";import{projectBoundingSphere as s}from"../../../../geometry/projection/projectBoundingSphere.js";import{f as n,h as o,u as r,c as a}from"../../../../chunks/sphere.js";import{i3sPatchingEnabled as l}from"../../../../support/featureFlags.js";import{expandElevationRange as d}from"./ElevationRange.js";import{LodMetric as h,NodeBase as u,Node as c,NodeFilterImpact as g,NodeIMModificationImpact as _,NodeTraversalState as f}from"./I3SNode.js";import{invalidateMbs as m,invalidateObb as v,addWraparound as N}from"./I3SUtil.js";import{clone as p}from"../../support/orientedBoundingBox.js";class b{constructor(e,t,i,s,n){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=n,this.useAsHole=0,this.filterImpact=g.NotChecked,this.traversalState=null,this.parent=-1}}class y{constructor(e=[],t=[]){this.nodes=e,this.children=t,this.lastTraversed=0,this.numNodesWithLoadedChildren=0}}class P{get _useNodePages(){return this._pageSize>0}constructor(t,i,s,n,o,r,a,d,u,c,g,_,f,m,v){this._layer=t,this._streamDataController=s,this._clientNodeLoader=n,this._viewportQueries=o,this._logger=r,this.holeFilling=a,this._isLoaded=d,this._isReloading=u,this._isSelected=c,this._enable=g,this._needsUpdate=_,this._canRequest=f,this._computeVisibilityObb=m,this._computeNodeFiltering=v,this._dirty=!0,this._nodePages=new Map,this._clientNodePage=null,this._pageSize=0,this._rootIndex=0,this._lodMetric=h.None,this._lodConversion=e=>e,this._isEditable=!1,this._urlPrefix="",this._loadingNodes=new Set,this._loadingPages=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._version=S(0),this._visibilityCacheVersion=S(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missingPagesAndNodes=new e({deallocator:null}),this._prefetchNodes=new e({deallocator:null}),this._updates=new I(this._missingPagesAndNodes),this._imModificationUncategorized=new e({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=new Array,this._newPages=new Array,this.needNodeElevationRange=!1,this.layerHasModifications=!1,this._layerHasFilter=!1,this._frameNumber=0,this._isEditable=l()&&null!=t.associatedLayer?.infoFor3D,t.serviceUpdateTimeStamp?.lastUpdate&&(this._lastUpdate=`${t.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this._viewportQueries?this._viewportQueries.maxLodLevel:1,this._init(i)}_init(e){if("page"===e.type){const t=e.rootPage;switch(this._urlPrefix=e.urlPrefix,this._pageSize=e.pageSize,e.lodMetric){case"maxScreenThreshold":this._lodMetric=h.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this._lodMetric=h.MaxScreenThreshold,this._lodConversion=z}if(this._isEditable){this._rootIndex=-1;const i=A(e.rootIndex,e.pageSize),s=t.nodes[i],n={nodes:[{index:this._rootIndex,children:[e.rootIndex],mesh:void 0,obb:s.obb,lodThreshold:s.lodThreshold}]};this._addPage(O(this._rootIndex,this._pageSize),n),this.getNode(-1).serviceObb=void 0}else this._rootIndex=e.rootIndex;this._addPage(O(e.rootIndex,this._pageSize),t),this._updateParentsAndLevel()}else if("node"===e.type){this._urlPrefix=e.urlPrefix;const t=new y;if(this._nodePages.set(0,t),this._isEditable){this._clientNodePage=new y;const t={id:"-1",version:null,mbs:e.rootNode.mbs,obb:e.rootNode.obb,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:[{id:"root",href:"../root",mbs:e.rootNode.mbs,obb:e.rootNode.obb}]};this._rootIndex=this._makeClientRefNode(new u(t.id,null),-1);const i=this._validateNode(t.id,t);i&&this._addNode(i,this._rootIndex)}else this._rootIndex=this._makeRefNode(new u(e.rootNode.id,null),-1);const i=this._validateNode(e.rootNode.id,e.rootNode);i&&this._addNode(i,0)}}addClientNodeToIndex(e,t){const i=-1,s=new u(e,t),n=this._makeClientRefNode(s,i);return this._linkChildToParentNode(i,n),this.requestUpdate(),n}removeClientNodeFromIndex(e,t,i){this._destroyClientRefNode(e,t,i),this.requestUpdate()}_loadPage(e){this._loadingPages.add(e);const i=this._urlPrefix+e;this._streamDataController.request(i,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((i=>{this._loadingPages.delete(e),t(i)||(this._failedPages.add(e),this._logger.error("#loadPage()",this._layer,`Error when loading page ${e}`,i))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loadingPages.delete(t),e.madeProgress(),this.needNodeElevationRange&&this._newPages.push(t)}this._updateParentsAndLevel()}_invalidateElevationRangeForNewPages(e){if(this.needNodeElevationRange)for(;this._newPages.length>0&&!e.done;){const e=this._nodePages.get(this._newPages.shift());if(null==e)continue;const t=e.nodes;for(let i=0;i<this._pageSize;i++){let e=t[i].parent;for(;null!=e&&e!==this._rootIndex;){const t=this.getNode(e);t&&!Number.isNaN(t?.elevationRangeMin)&&(t.invalidateElevationRange(),this.invalidateBoundingVolumeCache(e)),e=this.getParentIndex(e)}}}}_addPage(e,t){const s=[],o=[],r=t.nodes.map(((t,r)=>{const a=s.length,l=t.children?t.children.length:0;o.push(this._rootIndex);for(let e=0;e<l;e++)s.push(t.children[e]);const d=`${t.index}`,h=p(t.obb),u=n(h.center[0],h.center[1],h.center[2],i(h.halfSize)),g=t.mesh?.attribute,_=t.mesh?.geometry,f=t.mesh?.material,m={hasSharedResource:!1,isEmpty:null==_,attributes:null!=g?.resource?`${g.resource}`:void 0,geometry:null!=_?.resource?`${_.resource}`:void 0,texture:null!=f?.resource?`${f.resource}`:void 0,geometryDefinition:_?_.definition:-1,materialDefinition:f?f.definition:-1},v=new c(d,V(r,e,this._pageSize),u,l,0,m,this._lastUpdate,this._lodMetric,this._lodConversion(t.lodThreshold),_?_.featureCount:null);return v.serviceObb=h,v.visibilityObb=this._computeVisibilityObb(v),v.vertexCount=_?_.vertexCount:0,new b(a,l,w(this._visibilityCacheVersion),null,v)})),a=new y(r,s);-1===e?this._clientNodePage=a:this._nodePages.set(e,a)}_updateParentsAndLevel(){const e=new Array,t=(t,i,s)=>{const n=this._getPage(t);if(null!=n){const o=A(t,this._pageSize),r=n.nodes[o];r.parent=null!=i?i:-1;const a=r.node;null!=a&&(a.level=s,e.push(t))}};for(t(this._rootIndex,null,0);e.length;){const i=e.pop(),s=this.getNode(i);if(null!=s)for(let e=0;e<s.childCount;e++){t(this.getChildIndex(s.index,e),i,s.level+1),this._maxLevel=Math.max(this._maxLevel,s.level+1)}}}_getPage(e){const t=O(e,this._pageSize);return t<0?this._clientNodePage:this._nodePages.get(t)}_getNodeInternal(e){const t=this._getPage(e);return null==t?null:(t.lastTraversed=this._frameNumber,t.nodes[A(e,this._pageSize)])}_addNode(e,t){null!=e.children&&this.populateChildren(t,e.children);const i=this.getParent(t),s=null!=i?i.level+1:0;this._maxLevel=Math.max(this._maxLevel,e.children?s+1:s);const{lodMetric:n,maxError:o}=k(e.lodSelection),r=this._getNodeInternal(t);return r.node=new c(e.id,t,e.mbs,r.childCount,s,e.resources,e.version,n,o,e.numFeatures),e.obb&&(r.node.serviceObb=p(e.obb)),r.node.visibilityObb=this._computeVisibilityObb(r.node),null!=r.ref&&(null==r.ref.mbs&&(r.ref.mbs=e.mbs),r.node.renderMbs=r.ref.renderMbs,r.node.serviceObbInRenderSR=r.ref.serviceObbInRenderSR,r.ref.visibilityObb=r.node.visibilityObb),r.node}_makeRefNode(e,t){const i=this._nodePages.get(0);if(t<-1)return this._makeClientRefNode(e,t);if(null==i)return-1;const s=i.nodes.length,n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_makeClientRefNode(e,t){const i=this._clientNodePage;if(null==i)return-1;if(t>=0)throw new Error("I3SIndex::client side nodes can not be made children of service side nodes.");const s=-(i.nodes.length+1),n=new b(0,0,w(this._visibilityCacheVersion),e,null);return i.nodes.push(n),n.parent=t,m(e.renderMbs),v(e.serviceObbInRenderSR),s}_linkChildToParentNode(e,t){const i=this._clientNodePage;if(null==i||e>=0)return;const s=A(e,this._pageSize),n=A(t,this._pageSize),o=i.nodes[s],r=o.childOffset;i.children.splice(o.childOffset+o.childCount,0,t);const a=1;o.childCount+=a,null!=o.node&&(o.node.childCount+=a);for(const l of i.nodes)l.childOffset>r&&(l.childOffset+=a);i.nodes[n].parent=e,this._updateParentBoundingInformation(e)}_destroyClientRefNode(e,t,i){const s=this._clientNodePage;if(null==s)return;const n=this.getParentIndex(e);if(null==n)return;const o=new Set,r=new Map,a=e=>{const i=A(e,this._pageSize),n=s.nodes[i];if(n.childCount>0)for(let t=n.childOffset;t<n.childOffset+n.childCount;++t)a(s.children[t]);const r=n.node?.id??n.ref?.id;if(null==r)throw new Error("Node has no id");t(r,e),o.add(n)};a(e);const l=s.nodes,d=s.children,h=s.nodes.map((()=>-1)),u=[],c=[];for(let g=0;g<l.length;++g){const e=l[g];if(o.has(e))continue;const t=u.length,s=V(g,-1,this._pageSize),n=V(t,-1,this._pageSize);if(e.node&&(e.node.index=n),h[g]=n,u.push(e),s!==n){const t=e.node?.id??e.ref?.id;if(null==t)throw new Error("Node has no id");i(t,s,n),r.set(s,n)}}for(let g=0;g<u.length;++g){const e=V(g,-1,this._pageSize),t=u[g],i=c.length;for(let s=t.childOffset;s<t.childOffset+t.childCount;++s){const t=d[s];if(t>=0)c.push(t);else{const i=A(t,this._pageSize),s=l[i];if(o.has(s))continue;const n=h[i];c.push(n),s.parent=e}}t.childOffset=i,t.childCount=c.length-i,t.node&&(t.node.childCount=t.childCount)}s.nodes=u,s.children=c,this._updateParentBoundingInformation(h[A(n,this._pageSize)])}_updateParentBoundingInformation(e){let t=e;do{let e=null;const i=this._clientNodeLoader.indexSR,n=this._clientNodeLoader.renderSR,l=this._getNodeInternal(t);if(null==l)return;for(let a=0;a<l.childCount;a++){const l=this.getChildIndex(t,a),d=this._getNodeInternal(l),h=null!=d?d.ref||d.node:null;if(null!=h&&h.mbs[3]>0)if(null==e)e=o(h.mbs,D);else{const t=T,o=Q,a=U;s(h.mbs,i,t,n),s(e,i,o,n),r(t,o,a),s(a,n,e,i)}}const d=l.ref||l.node;null!=d&&(null!=e?d.mbs=o(e,null!=d.mbs?d.mbs:a()):m(d.mbs),m(d.renderMbs),v(d.serviceObbInRenderSR),d.geometryObb=null),this.invalidateNodeVisibilityCacheInternal(l),t=this.getParentIndex(t)}while(null!=t)}populateChildren(e,t){const i=this._getNodeInternal(e),s=this._getPage(e);i.childOffset=s.children.length,i.childCount=t.length;for(let n=0;n<t.length;n++){const i=this._makeRefNode(t[n],e);s.children.push(i)}}getNode(e){const t=this._getNodeInternal(e);return null!=t?t.node:null}getIndexById(e){let t;return this._forAllNodes(((i,s)=>{(null!=i.node&&i.node.id===e||null!=i.ref&&i.ref.id===e)&&(t=s)})),t}getNodeById(e){const t=this.getIndexById(e);return null!=t&&t>=0?this.getNode(t):null}getChildIndex(e,t){const i=this._getPage(e);if(null==i)return-1;const s=i.nodes[A(e,this._pageSize)];return i.children[s.childOffset+t]}getParentIndex(e){const t=this._getPage(e);return null!=t&&e!==this._rootIndex?t.nodes[A(e,this._pageSize)].parent:null}getParent(e){const t=this.getParentIndex(e);return null!=t?this.getNode(t):null}isLeaf(e){const t=this._getNodeInternal(e);return null!=t&&0===t.childCount}get rootNode(){return this.getNode(this._rootIndex)}get isEditable(){return this._isEditable}removeAllGeometryObbs(){this._forAllNodes((e=>{null!=e.node&&(e.node.geometryObb=null)}))}invalidateVisibilityCache(){this._visibilityCacheVersion=S(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(e){const t=this._getNodeInternal(e);null!=t&&this.invalidateNodeVisibilityCacheInternal(t)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=w(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(e){const t=this._getNodeInternal(e);null!=t&&(C(t),this.invalidateNodeVisibilityCacheInternal(t))}updateElevationChanged(e){const t=this._getNodeInternal(e);if(null==t)return;if(!this.needNodeElevationRange)return void this.invalidateBoundingVolumeCache(e);const i=null!=t.node?t.node:t.ref;null!=i&&i.invalidateElevationRange()}invalidateGeometryVisibility(e){const t=this._getNodeInternal(e);null!=t?.node&&(t.node.geometryObb=null,m(t.node.renderMbs),v(t.node.serviceObbInRenderSR))}invalidateVisibilityObbs(){null!=this.rootNode&&this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}_updateElevationRange(e){this._updateElevationRangeInternal(e,null)}_updateElevationRangeInternal(e,t){const i=this._getNodeInternal(e);if(!i)return!1;const s=i?.node??i?.ref;if(!s)return!1;const n=s.elevationRangeMin;if(!Number.isNaN(n))return d(t,s),!0;const o={elevationRangeMin:1/0,elevationRangeMax:-1/0};let r=!1;for(let l=0;l<i.childCount;l++){const t=this.getChildIndex(e,l);this._updateElevationRangeInternal(t,o)||(r=!0)}if(0===i.childCount||r){const e=!i.node?.resources.isEmpty;this._viewportQueries.expandElevationRange(s,e,o)}const a=s.elevationRangeMax;return Number.isNaN(n)||n!==o.elevationRangeMin||a!==o.elevationRangeMax?(i.node&&(i.node.elevationRangeMin=o.elevationRangeMin,i.node.elevationRangeMax=o.elevationRangeMax),i.ref&&(i.ref.elevationRangeMin=o.elevationRangeMin,i.ref.elevationRangeMax=o.elevationRangeMax),this.invalidateBoundingVolumeCache(e),d(t,s),!0):(d(t,s),!0)}isNodeVisible(e){const t=this._getNodeInternal(e);if(null==t||null!=t.ref&&!t.ref.mbs)return!0;if(this.needNodeElevationRange&&this._updateElevationRange(e),!M(t.visibilityCache,this._visibilityCacheVersion)){const e=t.node,i=!e||t.ref&&!e.visibilityObb?t.ref??null:e;if(this._layerHasFilter&&this._computeNodeFiltering&&(null!=e||null!=t.ref)&&t.filterImpact===g.NotChecked){const i=null!=e?e.mbs:null!=t.ref?t.ref.mbs:null;t.filterImpact=null!=i?this._computeNodeFiltering(i):g.Unmodified}const s=null!=e&&t.filterImpact===g.Culled,n=!(null!=e&&e.imModificationImpact===_.Culled)&&(!i||this._viewportQueries.isNodeVisible(i))&&!s;return t.visibilityCache=R(n,this._visibilityCacheVersion),n}return E(t.visibilityCache)}isGeometryVisible(e){if(!this.isNodeVisible(e))return!1;const t=this._getNodeInternal(e);return!!(null==t?.node?.geometryObb||this.layerHasModifications&&t.node.imModificationImpact===_.NotChecked)||this._viewportQueries.isGeometryVisible(t.node)}_traverseCoverage(e,t,i,s,n){const o=this._getPage(e);if(null==o||0===t.childCount)return;const r=t.childOffset+t.childCount,a=new Array;for(let l=t.childOffset;l<r;++l){const e=o.children[l],t=this._getNodeInternal(e);null!=t?.node&&this.isGeometryVisible(e)&&a.push(t)}s/=a.length;for(const l of a){const e=l.node.index;this._isLoaded(e)||this._isReloading(e)?(n.delta=Math.max(n.delta,i),n.coverage+=s):this._traverseCoverage(e,l,i+1,s,n)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const t=this._getNodeInternal(e);if(null==t)return!1;if("always"===this.holeFilling)return!0;if(M(t.useAsHole,this._version))return E(t.useAsHole);const i={delta:0,coverage:0};this._traverseCoverage(e,t,0,1,i);const s=i.delta*i.coverage<=.5;return t.useAsHole=R(s,this._version),s}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=S(this._version)}imModificationsChanged(e){this.layerHasModifications=e,this._forAllNodes((({node:e})=>{null!=e&&(e.imModificationImpact=_.NotChecked,e.visibilityObb=this._computeVisibilityObb(e),e.hasModifications&&this.invalidateGeometryVisibility(e.index))})),this.invalidateVisibilityCache()}layerFilterChanged(e){this._layerHasFilter=e,this._forAllNodes((e=>{if(null!=e){e.filterImpact=g.NotChecked;const t=e.node;null!=t&&this.invalidateNodeVisibilityCache(t.index)}})),this.invalidateVisibilityCache()}update(e,t,i){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(t),this._invalidateElevationRangeForNewPages(t),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missingPagesAndNodes.clear(),this._prefetchNodes.clear(),this._updates.reset(e),x.clear();let s=!0;const n=new F,o=new F,r=this._imModificationUncategorized;r.clear();const a=new Set,l=(l,d,h)=>{const u=O(l,this._pageSize);if(a.add(u),null==d){let e=this._entryPriority(l);return e===1/0&&(e=this._entryPriority(h)),x.set(u,Math.max(e,x.get(u)||0)),this._loadingPages.has(u)||this._failedPages.has(u)||this._missingPagesAndNodes.push(u),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const c=d.node;if(this._updateNodeFeatureEstimate(c,o),null==c){const e=this._entryPriority(l);return this._loadingNodes.has(l)||this._failedNodes.has(l)||(this._missingPagesAndNodes.push(l),x.set(l,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const g=this._getPage(l);if(0===this._missingPagesAndNodes.length&&!this._useNodePages)for(let e=0;e<d.childCount;e++){const t=g.children[d.childOffset+e],i=this._getNodeInternal(t);null==i||i.node||this._loadingNodes.has(t)||this._failedNodes.has(t)||(x.set(t,this._entryPriority(t)),this._prefetchNodes.push(t))}if(c.failed||c.resources.isEmpty)return void(s&&d.childCount>0&&this._isSelected(c)&&(s=!1));if(this._isLoaded(l)){if(n.known+=c.memory,++n.knownNodes,this._isSelected(c)?d.childCount>0&&(s=!1):(n.unremoved+=c.memory,s=!1),this._needsUpdate(c)){const e=this._entryPriority(l);x.set(l,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(l)}return}if(c.memory&&(n.known+=c.memory,++n.knownNodes),!this._isSelected(c))return void(this._isReloading(l)&&this._updates.remove.push(l));if(d.childCount>0&&(s=!1),c.memory?(n.missing+=c.memory,n.known+=c.memory,++n.knownNodes):++n.missingNodes,e.includes(c.index))return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(l)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==c.index)));if(!t.done&&this._enable(c))return void t.madeProgress();const f=this._entryPriority(l);x.set(l,f),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,f),this._updates.add.push(l),this.layerHasModifications&&i&&null!=c&&c.imModificationImpact===_.NotChecked&&r.push(l)};this.traverseVisible(l),this._frameNumber++,this._missingPagesAndNodes.sort(((e,t)=>e-t)),this._missingPagesAndNodes.filterInPlace(((e,t)=>t<1||this._missingPagesAndNodes.data[t-1]!==e)),this._missingPagesAndNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._missingPagesAndNodes.length>0&&(this._maxUnloadedPrio=x.get(this._missingPagesAndNodes.back()),this._prefetchNodes.clear());const d=this._updates.add;d.length>0&&this.layerHasModifications&&(r.length>0&&i?.(r),d.filterInPlace((e=>{const t=this._getNodeInternal(e),i=null==t?.node||t.node.imModificationImpact!==_.Culled;return i||this.invalidateNodeVisibilityCache(e),i}))),this._unloadedMemoryEstimate=n.missing-n.unremoved,n.knownNodes>3&&n.missingNodes>0&&(this._unloadedMemoryEstimate+=n.known/n.knownNodes*n.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(o),this._featureEstimate.leavesReached=s,this._updates.add.filterInPlace((e=>x.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>x.get(e)-x.get(t))),this._updates.update.sort(((e,t)=>x.get(e)-x.get(t))),this._indexMissing=this._loadingPages.size+this._loadingNodes.size+this._missingPagesAndNodes.length,this._dirty=this._indexMissing>0,x.clear()}checkFeatureTarget(e,t){const i=this._viewportQueries.updateScreenSpaceErrorBias(t);let s=t,n=t,o=i,r=10;for(;r--;){const i=new F;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===r)break;o=s,s=.5*(s+n)}else n=s,s=.5*(s+o)}return this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(e,t){this._version=S(this._version),this._viewportQueries.updateScreenSpaceErrorBias(e),this.traverseVisible(((e,i)=>this._updateNodeFeatureEstimate(null!=i?i.node:void 0,t)))}_updateNodeFeatureEstimate(e,t){null==e||e.failed||null==e.numFeatures||this._isSelected(e)&&(null!=e.numFeatures?(t.missing+=e.numFeatures,t.known+=e.numFeatures,++t.knownNodes):++t.missingNodes)}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missingPagesAndNodes)}prefetch(){return this._prefetchNodes.sort(((e,t)=>x.get(e)-x.get(t))),this._load(this._prefetchNodes)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();){const t=e.pop();this._useNodePages&&t>=0?this._loadPage(t):this._loadNode(t)}return!0}get isLoading(){return this._indexMissing>0}get isPrefetching(){return this._prefetchNodes.length>0}get indexLoading(){return this._loadingPages.size+this._loadingNodes.size}get indexMissing(){return this._indexMissing}get unloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}get maxPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}nodeTraversalState(e){if(null==e)return null;const t=e.index,i=this._getNodeInternal(t);if(!i)return null;let s=i?.traversalState;if(s&&M(s.version,this._version))return s;const n=this._viewportQueries.getLodLevel(e),o=this._viewportQueries.hasLOD(e);let r=!0;if(o){const e=this.getParentIndex(t);if(null!=e){const t=this._getNodeInternal(e),i=t?.traversalState;r=!!i&&n>i.lodLevel}else r=n>0}else r=0===e.childCount;return s?(s.lodLevel=n,s.isChosen=r,s.version=R(!0,this._version),s):(s=new f(o,r,n,R(!0,this._version)),i.traversalState=s,s)}async _loadNode(e){this._loadingNodes.add(e);const i=this._getNodeInternal(e).ref;if(null==i)return void this._failedNodes.add(e);const s=i.id,n=this._urlPrefix+s,o=()=>{this._loadingNodes.delete(e),0===this._missingPagesAndNodes.length&&0===this._loadingNodes.size&&this.requestUpdate()};let r=null;try{r=e>=0?await this._streamDataController.request(n,"json"):await this._clientNodeLoader.loadNodeJSON(s)}catch(d){return o(),void(t(d)||(this._logger.error("#loadNode()",this._layer,"Error loading node: "+n),this._failedNodes.add(e)))}o();const a=this._validateNode(s,r);if(null==a)return;a.obb&&this.invalidateNodeVisibilityCache(e);const l=this._addNode(a,e);this.nodeTraversalState(l)}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this._logger.error("#validateNode()",this._layer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this._logger.error("#validateNode()",this._layer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this._logger.warn("#validateNode()",this._layer,`Invalid shared resource href on node "${e}"`);const i=t.geometryData;null==i||Array.isArray(i)&&0===i.length||Array.isArray(i)&&1===i.length&&"./geometries/0"===i[0].href||this._logger.warn("#validateNode()",this._layer,`Invalid geometry data on node "${e}"`);const s=t.attributeData,n=this._layer.attributeStorageInfo;null==s||Array.isArray(s)&&!s.some(((e,t)=>e.href!==`./attributes/${n?.[t]?.key??`f_${t}`}/0`))||this._logger.warn("#validateNode()",this._layer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this._logger.warn("#validateNode()",this._layer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const o=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:void 0,a=t=>{if(null==t)return null;const i=t=>this._logger.error("#validateNode()",this._layer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this._logger.error("#validateNode()",this._layer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,n=new u(`${t.id}`,t.mbs);return n.serviceObb=s,n.visibilityObb=this._computeVisibilityObb(n),n},l=Array.isArray(t.children)?t.children.map(a).filter((e=>null!=e)):null,d=t.featureData?.length??!1,h=!0===t.isEmpty;return{id:e,mbs:t.mbs,obb:o,children:l,resources:{isEmpty:!d&&h,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:void 0,texture:t.textureData&&t.textureData.length>0?e:void 0,geometry:null!=t.geometryData?e:void 0},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:r}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((e=>{null!=e.node&&(e.node.failed=!1)}))}_entryPriority(e){const t=this._getNodeInternal(e),i=this.getParentIndex(e);if(null==t||null==i&&null==t.node)return null==i?1/0:this._entryPriority(i);let s=0;if(t.node&&null!=i){const e=this._getNodeInternal(i).traversalState;null!=e&&(s=e.lodLevel)}let n=this.progressiveLoadPenalty;for(let r=e;null!=r;r=this.getParentIndex(r))if(this._isLoaded(r)){n=0;break}const o=null!=t.ref?this._viewportQueries.distToPOI(t.ref):null!=t.node?this._viewportQueries.distToPOI(t.node):0;return-o-s*(o+this.progressiveLoadPenalty)+n}traverseVisible(e){const t=this._getNodeInternal(this._rootIndex);null!=t?this._traverseVisible(this._rootIndex,null,t,e):e(this._rootIndex,null,null)}_traverseVisible(e,t,i,s){if(i.node&&0===i.childCount)return void(this.isGeometryVisible(e)&&s(e,i,t));if(!this.isNodeVisible(e))return;if(s(e,i,t),null==i.node)return;const n=this.nodeTraversalState(i.node);if(n?.nodeHasLOD&&n.lodLevel===this._maxLodLevel)return;const o=this._getPage(e);for(let r=0;r<i.childCount;r++){const t=o.children[i.childOffset+r],n=this._getNodeInternal(t);n?this._traverseVisible(t,e,n,s):s(t,null,e)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(e,t){const i=e.index,s=this._getNodeInternal(i);null!=s&&this._traverseChildren(i,s,t)}_traverseChildren(e,t,i){const s=this._getPage(e);if(null==s)return;const n=t.childOffset+t.childCount;for(let o=t.childOffset;o<n;++o){const e=s.children[o],t=this._getNodeInternal(e);null!=t?.node&&i(t.node)&&this._traverseChildren(e,t,i)}}updateChildrenLoaded(e,t){let i=this.getNode(e);for(;null!=i;){const e=i.childrenLoaded,s=e+t;i.childrenLoaded=s;const n=0===e?1:0===s?-1:0,o=i.index;if(0!==n){this._getPage(o).numNodesWithLoadedChildren+=n}i=this.getParent(o)}}checkChildrenLoadedInvariant(){if(null==this.rootNode)return!0;const e=[],t=i=>{let s=this._isLoaded(i.index)||this._isReloading(i.index)?1:0;return this.traverseChildren(i,(e=>(s+=t(e),!1))),i.childrenLoaded!==s&&e.push(i.index),s};return t(this.rootNode),e.length&&this._logger.error("childrenLoaded invariant broken at following nodes: "+e.join(",")),e.length>0}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),e.index=this._nodePages.size*(this._pageSize||1)+(this._clientNodePage?.nodes.length??0),e.prio=this._maxProcessingPrio,(this._indexMissing||this._prefetchNodes.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetchNodes.length),this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}updateElevationInfo(e,t){this.needNodeElevationRange=t&&!!e&&("relative-to-ground"===e.mode||"on-the-ground"===e.mode),this._viewportQueries.updateElevationInfo(e),this.invalidateAllElevationRanges()}invalidateAllElevationRanges(){this._forAllNodes((e=>{C(e),null!=e.node&&e.node.invalidateElevationRange(),null!=e.ref&&e.ref.invalidateElevationRange()}))}_forAllNodes(e){if(null!=this._clientNodePage){const t=this._clientNodePage;for(let i=0;i<t.nodes.length;i++)e(t.nodes[i],-(i+1))}for(const[t,i]of this._nodePages){const s=t*this._pageSize;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}clearCaches(){if(this._useNodePages){const e=this._nodePages,t=new Set;this.traverseVisible((e=>t.add(O(e,this._pageSize))));for(const[i,s]of e)if(0!==s.numNodesWithLoadedChildren||t.has(i))for(const e of s.nodes)e.traversalState=null;else this._deleteNodePage(i)}}_deleteNodePage(e){this._nodePages.delete(e)}get test(){return{addNode:(e,t)=>this._addNode(e,t),getNodeInternal:e=>this._getNodeInternal(e),getPageIndex:e=>O(e,this._pageSize),getIndexWithinPage:e=>A(e,this._pageSize),getNodePage:e=>e<0?this._clientNodePage:this._nodePages.get(e),getChildIndices:e=>{const t=this._getNodeInternal(e),i=this._getPage(e);if(null==t||null==i)return[];const s=[];for(let n=t.childOffset;n<t.childOffset+t.childCount;++n)s.push(i.children[n]);return s},rootIndex:this._rootIndex,clientNodePage:this._clientNodePage,nodePages:this._nodePages}}}const x=new Map;class I{constructor(t){this.missing=t,this.update=new e({deallocator:null}),this.add=new e({deallocator:null}),this.remove=new e({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function C(e){null!=e.node&&(m(e.node.renderMbs),v(e.node.serviceObbInRenderSR)),null!=e.ref&&(m(e.ref.renderMbs),v(e.ref.serviceObbInRenderSR))}function w(e){return N(e,-2)}function S(e){return N(e,2)}function R(e,t){return t+(e?1:0)}function M(e,t){return(-2&e)===t}function E(e){return 1==(1&e)}function O(e,t){return e<0?-1:t>0?e/t|0:0}function A(e,t){return e<0?-e-1:0===t?e:e%t}function V(e,t,i){return-1===t?-(e+1):0===i?e:t*i+e}const L=[["maxScreenThreshold",h.MaxScreenThreshold],["screenSpaceRelative",h.ScreenSpaceRelative],["removedFeatureDiameter",h.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",h.DistanceRangeFromDefaultCamera]];function k(e){if(e)for(let t=0;t<e.length;t++)for(const i of L)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:h.None,maxError:0}}class F{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function z(e){return Math.sqrt(e*(4/Math.PI))}const D=a(),T=a(),Q=a(),U=a();export{P as I3SIndex,k as selectErrorMetric};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as p,isStringField as d,isTimeOnlyField as m,getFieldRange as y,TypeValidationError as h,NumericRangeValidationError as f,validateFieldValue as c}from"../../layers/support/fieldUtils.js";import{isAnyDateField as g}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as b}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as x,isFieldElementWithInputType as _,valueIsInvalidSwitchValue as V,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{timeResolutionToStepMap as w,isArcadeDate as N,arcadeDateToFieldValue as I,valueIsInRange as j}from"../support/dateUtils.js";var O;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(O||(O={}));const A="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return p(e)?O.Number:d(e)?O.Text:g(e)||m(e)?O.Date:O.Unsupported}get dateDataType(){if(this.dataType===O.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=x(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:A,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:A,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),u=this.element?.domain;return null!=u&&this._isDomainCompatible(u)?u:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==O.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==O.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=_(e,"switch")?e.input:null;return!t||V(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return b(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===O.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:n}=e,r=null!=l&&S(l)?l.getTime():null,u=null!=n&&S(n)?n.getTime():null,o=s(t)||y(i);if(!o)return{max:r,min:u};const a=o.max===Number.MAX_VALUE?null:o.max,p=o.min===Number.MIN_VALUE?null:o.min;return{max:null!=r&&(null===a||null!=a&&r<a)?r:a,min:null!=u&&(null===p||null!=p&&u>p)?u:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?w.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===O.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(N(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&d(t)||"number"===i&&p(t))return!0}return!!("range"===e?.type&&p(t)||g(t)||m(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:o,value:a}=this,p=s&&null==a,d=void 0!==o;return!p&&l.getAttribute(i.name)===a&&d?null:p?h.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof a&&a.length<n?D.TOO_SHORT:"date"===i.type&&null!=a&&r&&!j({value:a,max:r.max,min:r.min})?f.OUT_OF_RANGE:t?null!==a||s?u(t,a):null:c(i,a)}};e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),R=L;export{R as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as s,dateTimeFieldValuesToNumericRange as a,validateDomainValue as u}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as p,isNumericField as d,isStringField as m,isTimeOnlyField as y,getFieldRange as h,TypeValidationError as f,NumericRangeValidationError as c,validateFieldValue as g}from"../../layers/support/fieldUtils.js";import{isAnyDateField as b}from"../../smartMapping/support/utils.js";import{isRelatableFeatureSupportedLayer as x}from"../Feature/support/featureUtils.js";import v from"./EditableInput.js";import{parseFormTemplateString as E,getNormalizedFeatureTypeInfo as _,isFieldElementWithInputType as V,valueIsInvalidSwitchValue as w,isFieldElementWithTextInput as T,isFieldElementWithShowNoValueOptionInput as F,LengthValidationError as D}from"./featureFormUtils.js";import{isNumber as N}from"../support/dataUtils.js";import{timeResolutionToStepMap as j,isArcadeDate as A,arcadeDateToFieldValue as I,dateTimeIsInRange as O}from"../support/dateUtils.js";var M;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(M||(M={}));const R="__internal-type-based-coded-value-domain__";let L=class extends v{constructor(e){super(e),this._storedValue=null,this.error=null,this.preservesValueWhenHidden=!0,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this._fieldInputWasVisibleDuringLifetime=!1,this.valueExpressionExecutor=null}get _dateFormRange(){const{element:e,field:t}=this;if("date"!==this.dataType)return{};const i=e?.domain?s(t,e.domain):null;if(!e?.input)return i??{};const l=e.input,{type:n}=l;let r={};if("date-picker"!==n&&"time-picker"!==n&&"datetimeoffset-picker"!==n||(r=a(t,l.max,l.min)),"datetime-picker"===n){const{max:e,min:t}=l;r={max:null!=e&&S(e)?e.getTime():null,min:null!=t&&S(t)?t.getTime():null}}const{max:u,min:o}=r;if(i){const{max:e,min:t}=i,l=N(e)&&(null==u||null!=u&&e<u),n=N(t)&&(null==o||null!=o&&t>o);return{max:l?e:u??null,min:n?t:o??null,rawMax:l?i.rawMax:r?.rawMax??null,rawMin:n?i.rawMin:r?.rawMin??null}}return{min:o,max:u,rawMax:r?.rawMax??null,rawMin:r?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,field:t}=this;if("date"!==this.dataType)return{};const i=s(t);if(!i)return e;const{max:l,min:n,rawMax:r,rawMin:a}=e;if("date"===t.type){const{max:e,min:t}=i;return{max:N(l)&&(null===e||null!=e&&l<e)?l:e??null,min:N(n)&&(null===t||null!=t&&n>t)?n:t??null}}if("date-only"===t.type||"time-only"===t.type||"timestamp-offset"===t.type){const{max:e,min:t,rawMax:s,rawMin:u}=i,o=N(l)&&r&&(null==e||l<e);return{max:o?l:e,min:N(n)&&a&&(null==t||n>t)?n:t,rawMax:o?r:s,rawMin:o?a:u}}return{max:null,min:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return p(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get _isSubtypeField(){const{layer:e}=this;if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.name}return!1}get test(){return{_isSubtypeField:this._isSubtypeField}}get dataType(){const{field:e}=this;return d(e)?M.Number:m(e)?M.Text:b(e)||y(e)?M.Date:M.Unsupported}get dateDataType(){if(this.dataType===M.Date)return"date"!==this.field.type?"string":"number"}get description(){const{element:e,feature:t,layer:i,timeZone:l}=this,n=e?.description;return null!=i&&null!=n?E({label:n,attributes:t.attributes,fieldsIndex:i.fieldsIndex,timeZone:l}):n}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=_(e);if(this._isSubtypeField&&"subtypes"in e&&e.subtypes)return new r({name:R,codedValues:e.subtypes.map((({code:e,name:t})=>new n({code:e,name:t})))});if(t===this.name&&null==this.field.domain)return new r({name:R,codedValues:i.map((({code:e,name:t})=>new n({code:e,name:t})))});const{feature:l}=this,s=e?.getFieldDomain(this.name,{feature:l}),a=this.element?.domain;return null!=a&&this._isDomainCompatible(a)?a:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==M.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==M.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.element?.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get hasInvalidSwitchValue(){const{element:e}=this,t=V(e,"switch")?e.input:null;return!t||w(this.value,t)}get isRelationshipKeyField(){const{field:e,layer:t}=this;return x(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){const{element:e,feature:t,field:i,layer:l,timeZone:n}=this;return null!=l&&null!=e?.label?E({label:e.label,attributes:t.attributes,fieldsIndex:l.fieldsIndex,timeZone:n}):e?.label||i.alias||i.name}get maxLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.maxLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:l}get minLength(){const e=-1;if(this.dataType===M.Date)return e;const{field:t,element:i}=this,l=t?.length??-1,n=T(i)?i.input.minLength:NaN;return null!=n&&!isNaN(n)&&n>=e&&(l===e||n<=l)?n:e}get name(){return this.field?.name}get range(){const{domain:e,element:t,field:i}=this;if("date"===this.dataType)return this._dateRange;const l=s(i,e)||h(i,e),n=l?.max===Number.MAX_VALUE?null:l?.max??null,r=l?.min===-Number.MAX_VALUE?null:l?.min??null;if(!t?.domain||"range"!==t.domain.type)return{max:n,min:r};const{max:a,min:u}=s(i)||{};return{max:null!=a&&(null===n||null!=n&&a<n)?a:n,min:null!=u&&(null===r||null!=r&&u>r)?u:r}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l,_isSubtypeField:n}=this;return!!e&&(!1===i?.nullable||(!!n||!(!l||null==t)&&t))}set required(e){this._overrideIfSome("required",e)}get showNoValueOptionEnabled(){const{element:e}=this;return!this.required&&(!F(e)||e.input.showNoValueOption)}get showNoValueLabel(){const{element:e}=this;return F(e)?e.input.noValueOptionLabel:null}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get timeResolution(){const e=this.element?.input;if(e&&("datetimeoffset-picker"===e.type||"time-picker"===e.type))return e.timeResolution??"minutes"}get timeStep(){return null!=this.timeResolution?j.get(this.timeResolution):void 0}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t,visibilityExpressionExecutor:i,preservesValueWhenHidden:l}=this;return null!=t&&t.updating||null!=e&&e.updating||!1===l&&null!=i&&i.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._fieldInputWasVisibleDuringLifetime=this._fieldInputWasVisibleDuringLifetime||this.visible&&!1!==this.group?.visible,!1===this.preservesValueWhenHidden&&this._fieldInputWasVisibleDuringLifetime&&(!1===this.evaluatedVisibilityExpression||!1===this.group?.evaluatedVisibilityExpression))return null!==this._storedValue&&this.set("_storedValue",null),null;if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;return this.dataType===M.Date?this._arcadeOutputToDateFieldValue(e):null!=e&&"object"==typeof e?e.toString():e}return this._storedValue}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_arcadeOutputToDateFieldValue(e){const i=this.field.type;try{if("object"==typeof e){if(null===e)throw new t("feature-form:invalid-date-value");if(A(e))return I(e,i);if("getTime"in e&&"function"==typeof e.getTime&&"date"===i)return parseInt(e.getTime(),10);if("date-only"===i||"time-only"===i||"timestamp-offset"===i)return e.toString()}else{if("string"==typeof e)return"date"===i?parseInt(e,10):e;if("number"==typeof e&&"date"===i)return e}throw new t("feature-form:invalid-date-value")}catch{return"date"===i?NaN:""}}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&m(t)||"number"===i&&d(t))return!0}return!!("range"===e?.type&&d(t)||b(t)||y(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:n,range:r,required:s,valid:a,value:o}=this,p=s&&null==o,d=void 0!==a;return!p&&l.getAttribute(i.name)===o&&d?null:p?f.INVALID_TYPE:"text"===e&&n>-1&&"string"==typeof o&&o.length<n?D.TOO_SHORT:"date"!==e||null==o||O({type:i.type,range:r,value:o})?t?null!==o||s?u(i,o):null:g(i,o):c.OUT_OF_RANGE}};e([i()],L.prototype,"_dateFormRange",null),e([i()],L.prototype,"_dateRange",null),e([i()],L.prototype,"_storedValue",void 0),e([i()],L.prototype,"_configAllowsEdits",null),e([i()],L.prototype,"_layerAndFieldAllowEdits",null),e([i()],L.prototype,"_isVisibleByDefault",null),e([i()],L.prototype,"_isEditTrackingField",null),e([i()],L.prototype,"_shouldUseValueExpression",null),e([i()],L.prototype,"_isSubtypeField",null),e([i()],L.prototype,"dataType",null),e([i()],L.prototype,"dateDataType",null),e([i()],L.prototype,"description",null),e([i()],L.prototype,"domain",null),e([i()],L.prototype,"editable",null),e([i({readOnly:!0})],L.prototype,"error",void 0),e([i({constructOnly:!0})],L.prototype,"preservesValueWhenHidden",void 0),e([i()],L.prototype,"evaluatedRequiredExpression",null),e([i()],L.prototype,"evaluatedValueExpression",null),e([i()],L.prototype,"field",void 0),e([i()],L.prototype,"group",void 0),e([i({readOnly:!0})],L.prototype,"hint",null),e([i()],L.prototype,"includeDate",null),e([i()],L.prototype,"includeTime",null),e([i()],L.prototype,"includeTimeOffset",null),e([i()],L.prototype,"initialFeature",null),e([i({readOnly:!0})],L.prototype,"inputType",null),e([i()],L.prototype,"hasInvalidSwitchValue",null),e([i()],L.prototype,"isRelationshipKeyField",null),e([i()],L.prototype,"label",null),e([i()],L.prototype,"maxLength",null),e([i()],L.prototype,"minLength",null),e([i({readOnly:!0})],L.prototype,"name",null),e([i()],L.prototype,"range",null),e([i()],L.prototype,"required",null),e([i()],L.prototype,"requiredExpressionExecutor",void 0),e([i()],L.prototype,"showNoValueOptionEnabled",null),e([i()],L.prototype,"submittable",null),e([i()],L.prototype,"timeResolution",null),e([i()],L.prototype,"timeStep",null),e([i({readOnly:!0})],L.prototype,"type",void 0),e([i()],L.prototype,"updating",null),e([i()],L.prototype,"valid",null),e([i({value:null})],L.prototype,"value",null),e([i()],L.prototype,"valueExpressionExecutor",void 0),e([i()],L.prototype,"visible",null),L=e([l("esri.widgets.FeatureForm.FieldInput")],L);const S=e=>e&&!Number.isNaN(e.valueOf()),U=L;export{U as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as
|
|
5
|
+
import"../../intl.js";import{isSome as e}from"../../core/arrayUtils.js";import{neverReached as t}from"../../core/compilerUtils.js";import{templateHasKey as n,replace as r}from"../../core/string.js";import{DomainValidationError as i}from"../../layers/support/domainUtils.js";import{isTimeOnlyField as o,NumericRangeValidationError as l,TypeValidationError as a}from"../../layers/support/fieldUtils.js";import{isAnyDateField as s}from"../../smartMapping/support/utils.js";import{getLabelForDateFieldValue as u}from"../support/dateUtils.js";import{substitute as p}from"../../intl/substitute.js";const m=e=>"field"===e?.type,d=e=>"group"===e?.type,c=e=>"relationship"===e?.type,f=e=>!d(e)&&null!=e.group,y=e=>"field"===e.type,b=e=>"group"===e.type,T=e=>"relationship"===e.type,E=e=>e.reduce(((e,t)=>d(t)?[...e,...t.inputs]:[...e,t]),[]),g=e=>E(e).filter(m),v=e=>E(e).filter(c),O=e=>null!=e&&(x(e,"combo-box")||x(e,"radio-buttons")),x=(e,t)=>null!=e&&e.input?.type===t,j=e=>null!=e&&(x(e,"text-box")||x(e,"text-area")),V=({domain:e,inputType:t="text-box",dataType:n})=>"number"===n&&"text-box"===t&&(!e||"coded-value"!==e.type),h=e=>"items"in e,U={typeFieldName:null,types:[]};function N(t){const{attributes:r,fieldsIndex:i,label:o,timeZone:l}=t,a=Object.keys(r).filter((e=>n(o,e))),s=a.map((e=>r[e])),u=a.map((e=>i.get(e))).filter(e);return A(o,_({values:s,fields:u,timeZone:l}))}function _(e){const{fields:t,values:n,timeZone:r}=e,i=t.map(((e,t)=>{let i=n[t];if(e.domain&&"coded-value"===e.domain.type){const t=e.domain.codedValues.find((e=>e.code===i));t?.name&&(i=t.name)}return(s(e)||o(e))&&(i=u(e,i,{timeZone:"date"===e.type&&null!=r?r:void 0})),[e.name,i]}));return Object.fromEntries(i)}function A(e,t){return r(r(e,(e=>`{${e.toLowerCase()}}`)),Object.fromEntries(Object.entries(t).map((([e,t])=>[e.toLowerCase(),t]))))}const I=e=>e?"subtype-sublayer"===e.type?{typeFieldName:e.parent?.subtypeField,types:e.parent?.subtypes??[]}:"types"in e&&e.types?{typeFieldName:e.typeIdField,types:e.types.map((({id:e,name:t,domains:n})=>({code:e,name:t,domains:n})))}:U:U,L=(e,t)=>{if(!e)return!0;const{operations:n}=e;switch(t){case"INSERT":return n.supportsAdd;case"UPDATE":case"DELETE":return n.supportsUpdate;default:return!0}};var F;!function(e){e.TOO_SHORT="length-validation-error::too-short"}(F||(F={}));const D={type:"number"},R={type:"number",intlOptions:{notation:"scientific"}},Z={day:"2-digit",month:"2-digit",year:"numeric"},w={hour:"numeric",minute:"numeric",second:"numeric"},C={...Z,...w};function S(e){return e>=1e7||e<=-1e7}const G=(e,t,n)=>{const{dataType:r,error:o,minLength:s,value:u,required:m}=e;if(!t||!o)return null;if(m&&null===u)return t.validationErrors.cannotBeNull;if(o===i.VALUE_OUT_OF_RANGE||o===l.OUT_OF_RANGE){const{field:i,range:o}=e,l={type:"date",intlOptions:{..."time-only"===i.type?w:"date-only"===i.type?Z:C,timeZone:n??void 0}};return p(t.validationErrors.outsideRange,o,{format:{max:"date"===r?l:null!=o.max&&S(o.max)?R:D,min:"date"===r?l:null!=o.min&&S(o.min)?R:D}})}return o===i.INVALID_CODED_VALUE?t.validationErrors.invalidCodedValue:o===a.INVALID_TYPE?t.validationErrors.invalidType:o===F.TOO_SHORT?p(t.validationErrors.tooShort,{min:s}):null},H=e=>{if(!e)return;const t=e.layer,n=t&&"geometryType"in t?t.geometryType:void 0,r=e.geometry?.type;return"polyline"===r||"polyline"===n?"line":r||n||"table"},P=e=>{const t=[];if(e.formTemplate){const{description:r,title:i}=e.formTemplate;e.fields?.forEach((e=>{const o=i&&n(i,e.name),l=r&&n(r,e.name);(o||l)&&t.push(e.name)}))}return t};function k(e){if("formTemplate"in e&&e.formTemplate){return(e.formTemplate.elements?.filter(y)??[]).some((({fieldName:t})=>!e.fieldsIndex.get(t)))}return!1}function q(e,t){return null==e||t.onValue!==e&&t.offValue!==e}function B(e,n){switch(n.objectType){case"any":return!0;case"null":return null==e;case"code":return e===n.codedValue?.code;case"range":return null!=e&&null!=n.minValue&&null!=n.maxValue&&+e>=n.minValue&&+e<=n.maxValue;default:return t(n.objectType),!1}}export{F as LengthValidationError,L as capabilitiesAllowEditType,g as flattenFieldInputs,E as flattenInputs,v as flattenRelationshipInputs,k as formTemplateHasInvalidFields,_ as getComputedAttributes,G as getErrorMessageForFieldInput,P as getFieldsInTitleAndDesc,H as getIconForFeature,I as getNormalizedFeatureTypeInfo,y as isFieldElement,x as isFieldElementWithInputType,O as isFieldElementWithShowNoValueOptionInput,j as isFieldElementWithTextInput,m as isFieldInput,b as isGroupElement,d as isGroupInput,f as isInputInGroupInput,V as isNumberFieldInput,T as isRelationshipElement,c as isRelationshipInput,h as isTemplateItemGroup,N as parseFormTemplateString,A as substituteFieldTemplatesInString,q as valueIsInvalidSwitchValue,B as valueIsValidContingentValue};
|
package/widgets/FeatureForm.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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as y,numberingSystem as F,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as w,normalizeTimeOnlyString as O,getISOFieldValueFromDateComponents as k,getUnixFieldValueFromDateComponents as I}from"./support/dateUtils.js";import{globalCss as M}from"./support/globalCss.js";import{Heading as D,incrementHeadingLevel as x}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as V}from"./support/decorators/messageBundle.js";import{vmEvent as N}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";import{substitute as L}from"../intl/substitute.js";const j="data-field-name",S="esri.widgets.FeatureForm",E=o.getLogger(S);let U=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(E,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return T("div",{class:this.classes(p.base,M.widget,M.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return T("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&T(D,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&T("p",{class:p.description,key:"description"},e.formDescription);return T("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:T("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return T("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?x(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?L(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[T("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?T("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?T("label",{...s},r):T("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return T("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return T("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldCompnents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,y(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,max:a,min:s,key:r,readOnly:l}=t;return T("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"date","data-field-name":t[j],key:`${r}-date-input`,max:null!=a?`${a}`:void 0,min:null!=s?`${s}`:void 0,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:l,value:null!=o?`${o}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return T("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[j],key:`${a}-time-input`,numberingSystem:F,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,l=null!=n?`${n}`:void 0,{dateAsString:d,time:c,timeZoneOffset:u}=R(l),m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,numberingSystem:F,overlayPositioning:"fixed",readOnly:r,[j]:i,onfocus:this._onComponentFocus};return T("div",{class:p.dateInputContainer,key:`${s}-date-time-container`},T("calcite-input-date-picker",{...m,class:a,"data-date-part":"date",key:`${s}-date-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:d??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),T("calcite-input-time-picker",{...m,class:a,"data-date-part":"time",key:`${s}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:c??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?T("calcite-input-time-zone",{...m,class:a,"data-date-part":"timeZone",disabled:r,key:`${s}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:u??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldCompnents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,max:r,min:l,key:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:F,overlayPositioning:"fixed",readOnly:c,[j]:o,onfocus:this._onComponentFocus},{dateAsString:h,time:v}=w(a,u),_=null!=r?w(r,u):void 0,b=null!=l?w(l,u):void 0;return T("div",{class:p.dateInputContainer,key:`${d}-date-time-container`},T("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${d}-date-input`,max:_?.dateAsString??void 0,min:b?.dateAsString??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?T("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${d}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:v??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return T("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>T("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(T("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[T("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),T("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(T("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return T("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return T("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[j],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return T("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return T("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},T("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?T("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return T("calcite-list-item",{description:L(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},T("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return T("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return T("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},T("calcite-icon",{icon:b(i),scale:"m",slot:"content-start"}),T("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return T("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},T("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return T("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},T("span",null,e.label),t?T("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return T("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=L(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return T("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},T("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return T("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[j]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(j))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);g(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o}=t,n=this._dateComponentMap.get(o);if(!n)return;let a=this.viewModel.getValue(o),s=null;"date-only"===i?s=e.value:"time-only"===i?(a=O(a),s=O(e.value)):s="timestamp-offset"===i?null!=e.value?k({dateComponent:n.date,timeComponent:n.time,timeZoneComponent:n.timeZone,oldValue:a}):null:null!=e.value?I({oldValue:a,dateComponent:n.date,timeComponent:n.time,timeZone:this.timeZone,max:t.range?.max,min:t.range?.min}):null,null!==s&&e.value?a!==s&&this._updateFieldValue(o,s):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:E.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],U.prototype,"_listObserverNode",void 0),e([s()],U.prototype,"_relatedRecordsEnabled",null),e([s()],U.prototype,"disabled",null),e([s()],U.prototype,"feature",null),e([s()],U.prototype,"formTemplate",null),e([s()],U.prototype,"groupDisplay",void 0),e([s()],U.prototype,"headingLevel",void 0),e([s()],U.prototype,"label",null),e([s()],U.prototype,"layer",null),e([s()],U.prototype,"map",null),e([s(),V("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"messages",void 0),e([s(),V("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([s(),V("esri/widgets/Feature/t9n/Feature")],U.prototype,"messagesFeature",void 0),e([s(),V("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],U.prototype,"messagesTemplates",void 0),e([s()],U.prototype,"relatedRecordCallbacks",null),e([s()],U.prototype,"relationshipId",null),e([s()],U.prototype,"spatialReference",null),e([s()],U.prototype,"strict",null),e([s()],U.prototype,"timeZone",null),e([s()],U.prototype,"view",null),e([s(),N(["value-change","submit"])],U.prototype,"viewModel",void 0),U=e([r(S)],U);const $=U;export{$ as default};
|
|
5
|
+
import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{deprecatedProperty as i}from"../core/deprecate.js";import o from"../core/Logger.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as l}from"../layers/support/fieldUtils.js";import d from"./Widget.js";import{css as p}from"./FeatureForm/css.js";import{isGroupInput as c,isFieldInput as u,isRelationshipInput as m,isInputInGroupInput as h,isFieldElementWithInputType as v,getErrorMessageForFieldInput as _,getIconForFeature as b,isNumberFieldInput as g}from"./FeatureForm/featureFormUtils.js";import f from"./FeatureForm/FeatureFormViewModel.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{isString as y}from"./support/dataUtils.js";import{getLabelForDateFieldValue as F,numberingSystem as w,prepareISOFieldValueForDateComponents as R,prepareUnixFieldValueForDateComponents as O,normalizeTimeOnlyString as k,getISOFieldValueFromDateComponents as I,getUnixFieldValueFromDateComponents as M}from"./support/dateUtils.js";import{globalCss as D}from"./support/globalCss.js";import{Heading as x,incrementHeadingLevel as V}from"./support/Heading.js";import"./support/widgetUtils.js";import{messageBundle as N}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import{substitute as j}from"../intl/substitute.js";const E="data-field-name",U="esri.widgets.FeatureForm",S=o.getLogger(U);let $=class extends d{constructor(e,t){super(e,t),this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new f,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,relatedRecordCallbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,relatedRecordCallbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._inputsWithChanges.clear(),this._dateComponentMap.clear(),this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange()))])}loadDependencies(){return C({block:()=>import("@esri/calcite-components/dist/components/calcite-block.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox.js"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item.js"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),input:()=>import("@esri/calcite-components/dist/components/calcite-input.js"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker.js"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message.js"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number.js"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker.js"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone.js"),label:()=>import("@esri/calcite-components/dist/components/calcite-label.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button.js"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group.js"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch.js")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const e=this.relatedRecordCallbacks;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get relatedRecordCallbacks(){return this.viewModel.relatedRecordCallbacks}set relatedRecordCallbacks(e){this.viewModel.relatedRecordCallbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get view(){return i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view}set view(e){i(S,"view",{replacement:"Use FeatureForm.map instead.",version:"4.27"}),this.viewModel.view=e}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return L("div",{class:this.classes(p.base,D.widget,D.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return L("form",{class:p.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent())}_renderHeader(){const e=this.viewModel;if(!e.formHeaderVisible)return;const t=null!=e.formTitle&&L(x,{key:"title",level:this.headingLevel},e.formTitle),i=null!=e.formDescription&&L("p",{class:p.description,key:"description"},e.formDescription);return L("div",{class:p.formHeader},t,i)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderActiveRelationshipInput(e.activeRelationshipInput):e.inputs.filter(t).filter((e=>e.visible)).map(((e,t)=>c(e)?this._renderGroup(e,t):u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0))}_renderActiveRelationshipInput(e){return this._renderRelationshipInput(e)}_renderDescriptionOrEmpty(e,t){return null==e?null:L("div",{class:this.classes(p.description),id:t},e)}_renderGroup(e,t){const{disabled:i,formTemplate:o,headingLevel:n}=this,{description:a,inputs:s,label:r,open:l}=e,d=s.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),h=c?.group===e,v=`${this.id}_group_${t}`,_="sequential"===this.groupDisplay;return L("calcite-block",{class:this.classes(p.group,_?p.groupSequential:null,h?p.groupActive:null,i?p.inputDisabled:null),collapsible:!0,"data-group":e,description:a||void 0,disabled:i,heading:`${r}`,headingLevel:o?.title?V(n):n,id:v,key:v,open:l,onCalciteBlockToggle:({target:t})=>this._onGroupToggle(t,e)},d.map((e=>u(e)?this._renderLabeledField(e):m(e)?this._renderRelationshipInput(e):void 0)))}_getFocusableInput(e,t){const i=this.viewModel.allFieldInputs,o="forward"===e?i:i.slice().reverse();let n;if(!t||m(t))n=0;else if(c(t)){const e=t.inputs.find(u);n=e?o.indexOf(e):0}else{let i;if(h(t)&&!t.group.open){const o=t.group.inputs.filter(u);i="forward"===e?o[o.length-1]:o[0]}else i=t;n=o.indexOf(i)+1}for(let a=n;a<o.length;a++){const e=o[a];if(e.visible&&u(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:n,required:a}=e,s={"aria-label":a?j(this.messages.requiredFieldLabel,{name:o}):o,class:p.label,key:`${n.id}-${i.uid}-${e.name}`},r=[L("div",{class:p.labelTextContent,key:"labelTextContainer"},o,a?L("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?L("label",{...s},r):L("calcite-label",{...s},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:n}=e,a=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(n,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),a):this._renderComboBoxComponent(e,t,a):this._renderSwitchComponent(e,a)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,a):"number"===t?this._renderNumberComponent(e,a):this._renderStringComponent(e,a)}_renderStringComponent(e,t){return L("calcite-input",{...t,loading:e.updating,type:"text-area"===e.inputType?"textarea":"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.target)})}_renderNumberComponent(e,t){return L("calcite-input-number",{...t,integer:l(e.field),loading:e.updating,type:"number",onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.target)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,F(e.field,t.value,{timeZone:this.timeZone}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:n}=e,{class:a,key:s,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return L("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:a,"data-date-part":"date","data-field-name":t[E],key:`${s}-date-input`,max:y(l)?l:void 0,min:y(d)?d:void 0,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=n?`${n}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:n,key:a,readOnly:s}=t;return L("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:n,"data-date-part":"time","data-field-name":t[E],key:`${a}-time-input`,numberingSystem:w,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:s,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,valid:n,value:a}=e,{class:s,key:r,readOnly:l}=t,{rawMax:d,rawMin:c}=o,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:l,[E]:i,onfocus:this._onComponentFocus},m=R(d),h=R(c),v=R(a);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...u,class:s,"data-date-part":"date",key:`${r}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),L("calcite-input-time-picker",{...u,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:v.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}),e.includeTimeOffset?L("calcite-input-time-zone",{...u,class:s,"data-date-part":"timeZone",disabled:l,key:`${r}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:v.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:n,value:a}=e,{class:s,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,m={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:w,overlayPositioning:"fixed",readOnly:c,[E]:o,onfocus:this._onComponentFocus},h=O(a,u),v=O(l,u),_=O(d,u);return L("div",{class:p.dateInputContainer,key:`${r}-date-time-container`},L("calcite-input-date-picker",{...m,class:s,"data-date-part":"date",key:`${r}-date-input`,max:v?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:h.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.target)}),i?L("calcite-input-time-picker",{...m,class:s,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:h.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.target)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return L("calcite-input",{...i,class:this.classes(p.fieldInput,p.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:n}=e,{messages:a,messagesTemplates:s,viewModel:r,_inputsWithChanges:l}=this,d=t.map((e=>e.map((({name:e,value:t})=>L("calcite-combobox-item",{key:`#${t}`,selected:o===t,textLabel:e,value:`${t}`}))))),[p,c]=d;this.viewModel.fieldsWithInvalidCodedValue.has(e)&&c.unshift(L("calcite-combobox-item",{key:"incompatible-option",readOnly:!0,textLabel:`${e.value}`,value:`${e.value}`}));const u=c.length>0?[L("calcite-combobox-item-group",{key:"recommended",label:a.recommended},p),L("calcite-combobox-item-group",{key:"other",label:s.other},c)]:p,m="INSERT"===r.arcadeEditType,h=l.has(n),v=null==o&&(!m||h);if(e.showNoValueOptionEnabled){const t="",i=e.showNoValueLabel||a.empty;u.unshift(L("calcite-combobox-item",{key:"empty-option",selected:v,textLabel:a.empty,value:t},i))}const _=m&&e.showNoValueOptionEnabled&&!h?()=>{}:i.onblur;return L("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:_,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({target:e})=>{v&&0===e.selectedItems.length?this._ignoreDeselectionOfNoValueOption(e):this._saveValueFromComponent(e)}},u)}_renderRadioButtonComponents(e,t,i){const{name:o,value:n}=e,a=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===n,props:i})));if(e.showNoValueOptionEnabled){const t="",s=e.showNoValueLabel||this.messages.empty,r=n===t||null===n;a.unshift(this._renderRadioButtonComponent({key:"empty-option",label:s,name:o,value:t,selected:r,props:i}))}return L("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:p.inputRadioGroup,"data-field-name":i[E],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},a)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!v(e.element,"switch")&&i===e.element.input.onValue;return L("calcite-switch",{...t,checked:o,class:p.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.target)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:n,props:a}){return L("calcite-label",{class:p.inputRadioLabel,key:e,layout:"inline"},L("calcite-radio-button",{...a,afterCreate:void 0,afterUpdate:void 0,checked:o,class:p.inputRadio,disabled:a.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({target:e})=>{e.checked&&this._saveValueFromComponent(e)}}),n)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.valid?_(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?L("calcite-input-message",{icon:!0,status:"invalid"},i):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{relatedRecordCallbacks:n}=this;if(!o||!n?.showAllRelatedRecords)return;const a=this.messages;return L("calcite-list-item",{description:j(a.totalCount,{count:t}),label:a.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},L("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:n,relatedRecordCallbacks:a}=this;if(t&&a?.addRelatedRecord&&o)return L("calcite-button",{alignment:"center",appearance:"outline-fill",class:p.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>this._onAddRelatedRecordsClick(i,o),round:!0,scale:"s",width:"half"},e.relatedLayerIsTable?n.addRecord:n.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:n}=e,{feature:a,relatedRecordCallbacks:s}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),s?.editRelatedRecord&&a&&s.editRelatedRecord({parentFeature:a,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,p=r?()=>r.remove(i):void 0;return L("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:n,onclick:l,onmouseenter:d,onmouseleave:p,value:n},L("calcite-icon",{icon:b(i),scale:"m",slot:"content-start"}),L("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,n=o?null:this._renderDescriptionOrEmpty(e.description),a=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return L("calcite-label",{class:this.classes(p.label,p.relatedRecordsLabel),key:`relationship-${i}-container`},L("div",null,this._renderRelatedRecordsHeaderContainer(e),n,a),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return L("div",{class:p.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},L("span",null,e.label),t?L("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return L("calcite-list",{class:p.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,n=this.viewModel.findField(o),a=e.layer?.fieldsIndex.get(o),s=n?.label||a?.alias||o,r=j(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:s});return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return L("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},L("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return L("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:p.listObserver,key:"feature-observer"})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:n,maxLength:a,minLength:s,name:r,range:{max:l,min:d},required:c,valid:u,value:m}=e,h=this._inputsWithChanges.has(r),v=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(p.fieldInput,v?p.inputDisabled:null,h&&!u?p.inputInvalid:null),key:r,label:n,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:a>-1?a:void 0,minLength:s>-1?s:void 0,placeholder:o??void 0,readOnly:v,required:c,value:null==m?"":`${m}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[E]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(E))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value){const t=e.value,i=new ResizeObserver((()=>{e.value=void 0,e.value=t,i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);g(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,h(i)&&(i.group.open=!0),e.setFocus())}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null,this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=t.field.type,{name:o,range:n}=t,a=this._dateComponentMap.get(o);if(!a)return;let s=this.viewModel.getValue(o),r=null;"date-only"===i?r=e.value:"time-only"===i?(s=k(s),r=k(e.value)):r="timestamp-offset"===i?null!=e.value?I({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:s}):null:null!=e.value?M({oldValue:s,dateComponent:a.date,timeComponent:a.time,timeZone:this.timeZone,max:n.max,min:n.min}):null,null!==r&&e.value?s!==r&&this._updateFieldValue(o,r):this._updateFieldValue(o,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e);this._updateFieldValue(t.name,this._parseValue(e))}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&h(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){if(this.viewModel.setValue(e,t),this._inputsWithChanges.add(e),this.viewModel.fieldsWithContingentValues.has(e)){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return v(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:i}=e;0===i.length&&t&&"selected"in t?t.selected=!0:S.warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}};e([s()],$.prototype,"_listObserverNode",void 0),e([s()],$.prototype,"_relatedRecordsEnabled",null),e([s()],$.prototype,"disabled",null),e([s()],$.prototype,"feature",null),e([s()],$.prototype,"formTemplate",null),e([s()],$.prototype,"groupDisplay",void 0),e([s()],$.prototype,"headingLevel",void 0),e([s()],$.prototype,"label",null),e([s()],$.prototype,"layer",null),e([s()],$.prototype,"map",null),e([s(),N("esri/widgets/FeatureForm/t9n/FeatureForm")],$.prototype,"messages",void 0),e([s(),N("esri/t9n/common")],$.prototype,"messagesCommon",void 0),e([s(),N("esri/widgets/Feature/t9n/Feature")],$.prototype,"messagesFeature",void 0),e([s(),N("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],$.prototype,"messagesTemplates",void 0),e([s()],$.prototype,"relatedRecordCallbacks",null),e([s()],$.prototype,"relationshipId",null),e([s()],$.prototype,"spatialReference",null),e([s()],$.prototype,"strict",null),e([s()],$.prototype,"timeZone",null),e([s()],$.prototype,"view",null),e([s(),T(["value-change","submit"])],$.prototype,"viewModel",void 0),$=e([r(U)],$);const A=$;export{A as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
function n(n){return"number"==typeof n}function t(n){return"string"==typeof n||n instanceof String}export{n as isNumber,t as isString};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../intl.js";import n from"../../core/Error.js";import{clamp as
|
|
5
|
+
import"../../intl.js";import"../../core/has.js";import n from"../../core/Error.js";import{clamp as e}from"../../core/mathUtils.js";import{formatTimestamp as t,formatTimeOnly as o,formatDateOnly as l,formatDate as i}from"../../intl/date.js";import{utc as r}from"../../time/timeZoneUtils.js";import{isString as u,isNumber as a}from"./dataUtils.js";import{DateTime as s,FixedOffsetZone as m,Interval as f}from"luxon";import{getLocale as c}from"../../intl/locale.js";const d=r,y={date:null,time:null,timeZoneOffset:null},p=new Map([["hours",3600],["minutes",60],["seconds",1],["deciseconds",.1],["centiseconds",.01],["milliseconds",.001]]),v="yyyy-MM-dd",S="TT";var h;!function(n){n.HM="HH:mm",n.HMS="HH:mm:ss",n.HMS_MS="HH:mm:ss.SSS"}(h||(h={}));const M=[h.HMS_MS,h.HMS,h.HM,S],O="latn",g=new Set(["date-only","time-only","timestamp-offset"]),w=n=>"valueAsDate"in n;function H(n){return{locale:c(),numberingSystem:O,zone:n??d}}function j(n){return n?.isValid?n.toMillis():null}function V(n,e){return null===n?null:s.fromMillis(n,H(e))}function x(n){if(null==n||!u(n)||""===n)return y;const e=s.fromISO(n,{setZone:!0});return{date:e.toFormat(v,H()),time:e.toFormat(h.HMS_MS,H()),timeZoneOffset:e.offset.toString()}}function F(n,e){if(null==n||!a(n)||isNaN(n))return y;const t=V(n,e);return t?{date:t.toFormat(v,H(e)),time:t.toFormat(S,H(e))}:y}function I(n,e,r){if(!n||null==e)return null;switch(console.log("getLabelForDateFieldValue"),console.log(" -- value: ",e),console.log(" -- options: ",r),n.type){case"date":return i(e,r);case"date-only":return l(e,r);case"time-only":return o(e,r);case"timestamp-offset":return t(e,r);default:return null}}function Z(n){const{dateComponent:e,timeComponent:t,timeZoneComponent:o,oldValue:l}=n;if(!e?.value||!t?.value)return null;const{year:i,month:u,day:a}=s.fromFormat(e.value,v),{hour:f,minute:c,second:d,millisecond:y}=T(t,r)??s.now(),p=x(l),S=null!=o?.value?parseInt(o.value,10):null!=p.timeZoneOffset?parseInt(p.timeZoneOffset,10):(new Date).getTimezoneOffset(),h=m.instance(S),M=s.fromObject({year:i,month:u,day:a,hour:f,minute:c,second:d,millisecond:y},{zone:h});return M.isValid?M.toISO({includeOffset:!0}):null}function D(n){const{dateComponent:e,timeComponent:t,timeZone:o,max:l,min:i,oldValue:r}=n,u=T(e,o);let a=!!n.applyRange;if(!u)return null;let m=null;if(null!=t?.value){const n=T(t,o),e=Date.now(),i=null!=l&&l<e?l:e,r=s.fromMillis(i,H(o)),a=u||r,{year:f,month:c,day:d}=a,{hour:y,minute:p,second:v,millisecond:S}=n||r;m=a.set({year:f,month:c,day:d,hour:y,minute:p,second:v,millisecond:S})}else{const n=V(C({value:r??Date.now(),max:l,min:i}),o),{year:e,month:t,day:s}=u,{hour:f,minute:c,second:d,millisecond:y}=n;a=!0,m=u.set({year:e,month:t,day:s,hour:f,minute:c,second:d,millisecond:y})}if(!m.isValid)return null;const f=m.toMillis();return a?C({value:f,max:l,min:i}):f}function T(n,e){if(!n||null==n.value||Array.isArray(n.value))return null;let t=null;return t=w(n)?s.fromFormat(n.value,v,H(e)):_(n.value),t?.isValid?t:null}function b(n){const{max:e,min:t,value:o}=n;return!isNaN(o)&&(!(null!=e&&o>e)&&!(null!=t&&o<t))}function C(n){const{max:t,min:o,value:l}=n;return null!=t&&null!=o?e(l,o,t):null!=t&&l>t?t:null!=o&&l<o?o:l}function A(e){if(!e)return"";const t=e.split(".").at(0);if(!t||t.length<1)throw new n("invalid time-only field",`Cannot parse valid time-only field value from ${e}`);const o=t.split(":"),l=new Array(3);for(let n=0;n<3;n++){const e=o.at(n)??"";l[n]=e.padStart(2,"0")}return l.join(":")}function N(n,e){switch(e){case"date":return n.getTime();case"date-only":return n.toISODate();case"time-only":return A(n.toISOTime(!0,!1));case"timestamp-offset":return n.toISOString(!1);default:return null}}function z(n){return!!n&&"object"==typeof n&&"getTime"in n&&"toISOString"in n&&"timeZone"in n}function U(n){return s.fromFormat(n,v)}function _(n){let e=null;return M.find((t=>(e=s.fromFormat(n,t),e.isValid))),e}function k(n){return s.fromISO(n)}function E(n){const{type:e,range:t,value:o}=n;if(null==o||!t)return!0;if("date"===e)return b({value:o,min:t.min,max:t.max});const{rawMax:l,rawMin:i}=t;if(!u(l)||!u(i)||!u(o))return!0;let r=null,a=null,s=null;switch(e){case"date-only":r=U(l),a=U(i),s=U(o);break;case"time-only":r=_(l),a=_(i),s=_(o);break;case"timestamp-offset":r=k(l),a=k(i),s=k(o)}return!(r?.isValid&&a?.isValid&&s?.isValid)||(f.fromDateTimes(a,r).contains(s)||a.valueOf()===s.valueOf()||r.valueOf()===s.valueOf())}export{h as TimeStampOffsetPattern,N as arcadeDateToFieldValue,C as clampValueToRange,V as createDateTimeFromFieldValue,g as dateFieldsWithStringFieldValue,U as dateOnlyToDateTime,E as dateTimeIsInRange,j as dateTimeToFieldValue,v as defaultDatePattern,S as defaultTimePattern,H as getDefaultLocaleOptions,Z as getISOFieldValueFromDateComponents,I as getLabelForDateFieldValue,T as getLocalDateTimeFromComponent,D as getUnixFieldValueFromDateComponents,z as isArcadeDate,w as isCalciteDateComponent,A as normalizeTimeOnlyString,O as numberingSystem,x as prepareISOFieldValueForDateComponents,F as prepareUnixFieldValueForDateComponents,M as supportedTimeFormats,_ as timeOnlyToDateTime,p as timeResolutionToStepMap,k as timestampOffsetToDateTime,b as valueIsInRange};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[8062,8008],{7335:(e,a,r)=>{r.d(a,{L:()=>n});var t=r(96187);class n{constructor(){this._serviceMetadatas=new Map}async fetchServiceMetadata(e,a){const r=this._serviceMetadatas.get(e);if(r)return r;const n=await(0,t.T)(e,a);return this._serviceMetadatas.set(e,n),n}}},71592:(e,a,r)=>{r.d(a,{w:()=>y});var t=r(40330),n=r(3172),i=r(20102),l=r(95330),s=r(66677),o=r(48522),c=r(15235);async function y(e,a){const r=(0,s.Qc)(e);if(!r)throw new i.Z("invalid-url","Invalid scene service url");const y={...a,sceneServerUrl:r.url.path,layerId:r.sublayer??void 0};if(y.sceneLayerItem??=await async function(e){const a=(await u(e)).serviceItemId;if(!a)return null;const r=new c.default({id:a,apiKey:e.apiKey}),i=await async function(e){const a=t.id?.findServerInfo(e.sceneServerUrl);if(a?.owningSystemUrl)return a.owningSystemUrl;const r=e.sceneServerUrl.replace(/(.*\/rest)\/.*/i,"$1")+"/info";try{const a=(await(0,n.Z)(r,{query:{f:"json"},responseType:"json",signal:e.signal})).data.owningSystemUrl;if(a)return a}catch(e){(0,l.r9)(e)}return null}(e);null!=i&&(r.portal=new o.Z({url:i}));try{return r.load({signal:e.signal})}catch(e){return(0,l.r9)(e),null}}(y),null==y.sceneLayerItem)return d(y.sceneServerUrl.replace("/SceneServer","/FeatureServer"),y);const p=await async function({sceneLayerItem:e,signal:a}){if(!e)return null;try{const r=(await e.fetchRelatedItems({relationshipType:"Service2Service",direction:"reverse"},{signal:a})).find((e=>"Feature Service"===e.type))||null;if(!r)return null;const t=new c.default({portal:r.portal,id:r.id});return await t.load(),t}catch(e){return(0,l.r9)(e),null}}(y);if(!p?.url)throw new i.Z("related-service-not-found","Could not find feature service through portal item relationship");const f=await d(p.url,y);return f.portalItem=p,f}async function u(e){if(e.rootDocument)return e.rootDocument;const a={query:{f:"json",token:e.apiKey},responseType:"json",signal:e.signal};try{const r=await(0,n.Z)(e.sceneServerUrl,a);e.rootDocument=r.data}catch{e.rootDocument={}}return e.rootDocument}async function d(e,a){const r=(0,s.Qc)(e);if(!r)throw new i.Z("invalid-feature-service-url","Invalid feature service url");const t=r.url.path,l=a.layerId;if(null==l)return{serverUrl:t};const o=u(a),c=e=>{const r={query:{f:"json"},responseType:"json",authMode:e,signal:a.signal};return(0,n.Z)(t,r)},y=c("anonymous").catch((()=>c("no-prompt"))),[d,p]=await Promise.all([y,o]),f=p?.layers,L=d.data&&d.data.layers;if(!Array.isArray(L))throw new Error("expected layers array");if(Array.isArray(f)){for(let e=0;e<Math.min(f.length,L.length);e++)if(f[e].id===l)return{serverUrl:t,layerId:L[e].id}}else if(null!=l&&l<L.length)return{serverUrl:t,layerId:L[l].id};throw new Error("could not find matching associated sublayer")}},52104:(e,a,r)=>{r.d(a,{V:()=>n});var t=r(96187);async function n(e,a){const r=await(0,t.T)(e,a);r.layers=r.layers.filter(i);const n={serviceJSON:r};if((r.currentVersion??0)<10.5)return n;const l=await(0,t.T)(e+"/layers",a);return n.layersJSON={layers:l.layers.filter(i),tables:l.tables},n}function i(e){return!e.type||"Feature Layer"===e.type||"Oriented Imagery Layer"===e.type}},70024:(e,a,r)=>{r.d(a,{k:()=>M,populateOperationalLayers:()=>y});var t=r(46791),n=(r(80442),r(7335)),i=r(87344),l=r(15235);function s(e,a){return!(!e.layerType||"ArcGISFeatureLayer"!==e.layerType)&&e.featureCollectionType===a}var o=r(28008),c=r(40555);async function y(e,a,r){if(!a)return;const t=[];for(const e of a)t.push(g(e,r));const n=await Promise.allSettled(t);for(const a of n)"rejected"===a.status||a.value&&e.add(a.value)}const u={ArcGISDimensionLayer:"DimensionLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",PointCloudLayer:"PointCloudLayer",ArcGISSceneServiceLayer:"SceneLayer",IntegratedMeshLayer:"IntegratedMeshLayer",OGCFeatureLayer:"OGCFeatureLayer",BuildingSceneLayer:"BuildingSceneLayer",ArcGISTiledElevationServiceLayer:"ElevationLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",GroupLayer:"GroupLayer",GeoJSON:"GeoJSONLayer",WebTiledLayer:"WebTileLayer",CSV:"CSVLayer",VectorTileLayer:"VectorTileLayer",WFS:"WFSLayer",WMS:"WMSLayer",DefaultTileLayer:"TileLayer",KML:"KMLLayer",RasterDataLayer:"UnsupportedLayer",Voxel:"VoxelLayer",LineOfSightLayer:"LineOfSightLayer"},d={ArcGISTiledElevationServiceLayer:"ElevationLayer",DefaultTileLayer:"ElevationLayer",RasterDataElevationLayer:"UnsupportedLayer"},p={ArcGISFeatureLayer:"FeatureLayer"},f={ArcGISTiledMapServiceLayer:"TileLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",OpenStreetMap:"OpenStreetMapLayer",WebTiledLayer:"WebTileLayer",VectorTileLayer:"VectorTileLayer",ArcGISImageServiceLayer:"UnsupportedLayer",WMS:"UnsupportedLayer",ArcGISMapServiceLayer:"UnsupportedLayer",ArcGISSceneServiceLayer:"SceneLayer",DefaultTileLayer:"TileLayer"},L={ArcGISAnnotationLayer:"UnsupportedLayer",ArcGISDimensionLayer:"UnsupportedLayer",ArcGISFeatureLayer:"FeatureLayer",ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISStreamLayer:"StreamLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",BingMapsAerial:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",CSV:"CSVLayer",DefaultTileLayer:"TileLayer",GeoRSS:"GeoRSSLayer",GeoJSON:"GeoJSONLayer",GroupLayer:"GroupLayer",KML:"KMLLayer",MediaLayer:"MediaLayer",OGCFeatureLayer:"OGCFeatureLayer",OrientedImageryLayer:"OrientedImageryLayer",SubtypeGroupLayer:"SubtypeGroupLayer",VectorTileLayer:"VectorTileLayer",WFS:"WFSLayer",WMS:"WMSLayer",WebTiledLayer:"WebTileLayer"},m={ArcGISFeatureLayer:"FeatureLayer"},w={ArcGISImageServiceLayer:"ImageryLayer",ArcGISImageServiceVectorLayer:"ImageryLayer",ArcGISMapServiceLayer:"MapImageLayer",ArcGISTiledImageServiceLayer:"ImageryTileLayer",ArcGISTiledMapServiceLayer:"TileLayer",OpenStreetMap:"OpenStreetMapLayer",VectorTileLayer:"VectorTileLayer",WebTiledLayer:"WebTileLayer",BingMapsAerial:"BingMapsLayer",BingMapsRoad:"BingMapsLayer",BingMapsHybrid:"BingMapsLayer",WMS:"WMSLayer",DefaultTileLayer:"TileLayer"},S={...L,LinkChartLayer:"LinkChartLayer"},h={...m},I={...w};async function g(e,a){return async function(e,a,r){const t=new e;return t.read(a,r.context),"group"===t.type&&("GroupLayer"===a.layerType?await M(t,a,r):v(a)?function(e,a,r){a.itemId&&(e.portalItem=new l.default({id:a.itemId,portal:r?.portal}),e.when((()=>{const t=t=>{const n=t.layerId;G(t,e,a,n,r);const i=a.featureCollection?.layers?.[n];i&&t.read(i,r)};e.layers?.forEach(t),e.tables?.forEach(t)})))}(t,a,r.context):b(a)&&await async function(e,a,r){const t=i.T.FeatureLayer,n=await t(),l=a.featureCollection,s=l?.showLegend,o=l?.layers?.map(((t,i)=>{const l=new n;l.read(t,r);const o={...r,ignoreDefaults:!0};return G(l,e,a,i,o),null!=s&&l.read({showLegend:s},o),l}));e.layers.addMany(o??[])}(t,a,r.context)),await(0,c.y)(t,r.context),t}(await async function(e,a){const r=a.context,t=T(r);let c=e.layerType||e.type;!c&&a?.defaultLayerType&&(c=a.defaultLayerType);const y=t[c];let u=y?i.T[y]:i.T.UnknownLayer;if(v(e)){const a=r?.portal;if(e.itemId){const r=new l.default({id:e.itemId,portal:a});await r.load();const t=(await(0,o.v)(r,new n.L)).className||"UnknownLayer";u=i.T[t]}}else"ArcGISFeatureLayer"===c?function(e){return s(e,"notes")}(e)||function(e){return s(e,"markup")}(e)?u=i.T.MapNotesLayer:function(e){return s(e,"route")}(e)?u=i.T.RouteLayer:b(e)&&(u=i.T.GroupLayer):e.wmtsInfo?.url&&e.wmtsInfo.layerIdentifier?u=i.T.WMTSLayer:"WFS"===c&&"2.0.0"!==e.wfsInfo?.version&&(u=i.T.UnsupportedLayer);return u()}(e,a),e,a)}function b(e){return"ArcGISFeatureLayer"===e.layerType&&!v(e)&&(e.featureCollection?.layers?.length??0)>1}function v(e){return"Feature Collection"===e.type}function T(e){let a;switch(e.origin){case"web-scene":switch(e.layerContainerType){case"basemap":a=f;break;case"ground":a=d;break;case"tables":a=p;break;default:a=u}break;case"link-chart":switch(e.layerContainerType){case"basemap":a=I;break;case"tables":a=h;break;default:a=S}break;default:switch(e.layerContainerType){case"basemap":a=w;break;case"tables":a=m;break;default:a=L}}return a}async function M(e,a,r){const n=new t.Z,i=y(n,Array.isArray(a.layers)?a.layers:[],r);try{try{if(await i,"group"===e.type)return e.layers.addMany(n),e}catch(a){e.destroy();for(const e of n)e.destroy();throw a}}catch(e){throw e}}function G(e,a,r,t,n){e.read({id:`${a.id}-sublayer-${t}`,visibility:r.visibleLayers?.includes(t)??!0},n)}},87344:(e,a,r)=>{r.d(a,{T:()=>t});const t={BingMapsLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(8153)]).then(r.bind(r,2723))).default,BuildingSceneLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(4680),r.e(9238),r.e(6170),r.e(1767),r.e(4681),r.e(3554)]).then(r.bind(r,30223))).default,CSVLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(4680),r.e(9238),r.e(7587)]).then(r.bind(r,45425))).default,DimensionLayer:async()=>(await Promise.all([r.e(163),r.e(9717)]).then(r.bind(r,40081))).default,ElevationLayer:async()=>(await Promise.all([r.e(163),r.e(6569),r.e(9016),r.e(2763)]).then(r.bind(r,65665))).default,FeatureLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(4680),r.e(9238),r.e(447)]).then(r.bind(r,19238))).default,GeoJSONLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(8621)]).then(r.bind(r,23477))).default,GeoRSSLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(6e3)]).then(r.bind(r,3723))).default,GroupLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9059)]).then(r.bind(r,40504))).default,ImageryLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(4599),r.e(6610),r.e(1319),r.e(4608)]).then(r.bind(r,60590))).default,ImageryTileLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(6610),r.e(4136),r.e(1319),r.e(9532)]).then(r.bind(r,74878))).default,IntegratedMeshLayer:async()=>(await Promise.all([r.e(163),r.e(1767),r.e(1537)]).then(r.bind(r,9310))).default,KMLLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(1423),r.e(6413)]).then(r.bind(r,42756))).default,LineOfSightLayer:async()=>(await Promise.all([r.e(163),r.e(4998)]).then(r.bind(r,21786))).default,LinkChartLayer:async()=>(await Promise.all([r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(6404),r.e(8968),r.e(3794),r.e(5129)]).then(r.bind(r,19087))).default,MapImageLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(4599),r.e(9735),r.e(2725),r.e(7374)]).then(r.bind(r,27374))).default,MapNotesLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(4680),r.e(9238),r.e(6618)]).then(r.bind(r,62128))).default,MediaLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(4828)]).then(r.bind(r,57765))).default,OGCFeatureLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(3966),r.e(3809)]).then(r.bind(r,88068))).default,OpenStreetMapLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9971),r.e(6237)]).then(r.bind(r,66237))).default,OrientedImageryLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(4680),r.e(9238),r.e(178)]).then(r.bind(r,44958))).default,PointCloudLayer:async()=>(await Promise.all([r.e(163),r.e(8775),r.e(1767),r.e(7863)]).then(r.bind(r,10608))).default,RouteLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(1423),r.e(9206)]).then(r.bind(r,40153))).default,SceneLayer:async()=>(await Promise.all([r.e(163),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(6170),r.e(1767),r.e(4681),r.e(299)]).then(r.bind(r,57476))).default,StreamLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(3847)]).then(r.bind(r,88387))).default,SubtypeGroupLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(4680),r.e(7157),r.e(7701)]).then(r.bind(r,20697))).default,TileLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(957),r.e(1423),r.e(3778),r.e(4599),r.e(9735),r.e(9016),r.e(2725),r.e(8636)]).then(r.bind(r,98636))).default,UnknownLayer:async()=>(await r.e(4166).then(r.bind(r,44166))).default,UnsupportedLayer:async()=>(await r.e(9296).then(r.bind(r,39296))).default,VectorTileLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9016),r.e(4325),r.e(9805),r.e(5481)]).then(r.bind(r,94756))).default,VoxelLayer:async()=>(await Promise.all([r.e(163),r.e(8775),r.e(1767),r.e(7528)]).then(r.bind(r,28865))).default,WFSLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7899),r.e(6569),r.e(957),r.e(1423),r.e(3778),r.e(6404),r.e(8089),r.e(5245)]).then(r.bind(r,12653))).default,WMSLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9790),r.e(8775),r.e(7915)]).then(r.bind(r,25906))).default,WMTSLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9971),r.e(2594)]).then(r.bind(r,72594))).default,WebTileLayer:async()=>(await Promise.all([r.e(163),r.e(4609),r.e(9971)]).then(r.bind(r,16199))).default}},33516:(e,a,r)=>{r.d(a,{M4:()=>o,Yv:()=>l,ht:()=>i,wk:()=>s});var t=r(17452),n=r(48522);function i(e){return{origin:"portal-item",url:(0,t.mN)(e.itemUrl),portal:e.portal||n.Z.getDefault(),portalItem:e,readResourcePaths:[]}}function l(e){const a=(0,t.mN)(e.itemUrl);return{origin:"portal-item",messages:[],writtenProperties:[],url:a,portal:e.portal||n.Z.getDefault(),portalItem:e,verifyItemRelativeUrls:a?{rootPath:a.path,writtenUrls:[]}:null,blockedRelativeUrls:[]}}function s(e){return{origin:"web-map",url:(0,t.mN)(e.itemUrl),portal:e.portal||n.Z.getDefault(),portalItem:e,readResourcePaths:[]}}function o(e,a){const r=(0,t.mN)(e.itemUrl);return{origin:"web-map",messages:[],writtenProperties:[],url:r,portal:e.portal||n.Z.getDefault(),portalItem:e,initiator:a,verifyItemRelativeUrls:r?{rootPath:r.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}}}},18062:(e,a,r)=>{r.d(a,{load:()=>L});var t=r(20102),n=r(66677),i=r(52104),l=r(7335),s=r(70024),o=r(87344),c=r(48522),y=r(33516),u=r(3072),d=r(14661),p=r(40555),f=r(96187);async function L(e,a){const r=e.instance.portalItem;if(r?.id)return await r.load(a),function(e){const a=e.instance.portalItem;if(!a?.type||!e.supportedTypes.includes(a.type))throw new t.Z("portal:invalid-layer-item-type","Invalid layer item type '${type}', expected '${expectedType}'",{type:a?.type,expectedType:e.supportedTypes.join(", ")})}(e),async function(e,a){const r=e.instance,n=r.portalItem;if(!n)return;const{url:o,title:c}=n,L=(0,y.ht)(n);if("group"===r.type)return async function(e,a,r){const n=e.portalItem;if(!e.sourceIsPortalItem)return;const{title:o,type:c}=n;if("Group Layer"===c){if(!(0,d._$)(n,"Map"))throw new t.Z("portal:invalid-layer-item-typekeyword","'Group Layer' item without 'Map' type keyword is not supported");return async function(e){const a=e.portalItem,r=await a.fetchData("json");if(!r)return;const t=(0,y.wk)(a);e.read(r,t),await(0,s.k)(e,r,{context:t}),e.resourceReferences={portalItem:a,paths:t.readResourcePaths??[]}}(e)}return e.read({title:o},a),async function(e,a){let r;const{portalItem:n}=e;if(!n)return;const s=n.type,o=a.layerModuleTypeMap;switch(s){case"Feature Service":case"Feature Collection":r=o.FeatureLayer;break;case"Stream Service":r=o.StreamLayer;break;case"Scene Service":r=o.SceneLayer;break;default:throw new t.Z("portal:unsupported-item-type-as-group",`The item type '${s}' is not supported as a 'IGroupLayer'`)}const c=new l.L;let[y,d]=await Promise.all([r(),S(a,c)]),p=()=>y;if("Feature Service"===s){d=n.url?await(0,u.$O)(d,n.url,c):{};const a=(0,u.XX)(d),r=(0,u._Y)(d),t=[];if(a.length||r?.length){a.length&&t.push("SubtypeGroupLayer"),r?.length&&t.push("OrientedImageryLayer");const e=[];for(const a of t){const r=o[a];e.push(r())}const n=await Promise.all(e),i=new Map;t.forEach(((e,a)=>{i.set(e,n[a])})),p=e=>e.layerType?i.get(e.layerType)??y:y}const l=await async function(e){const{layersJSON:a}=await(0,i.V)(e);if(!a)return null;const r=[...a.layers,...a.tables];return e=>r.find((a=>a.id===e.id))}(n.url);return await m(e,p,d,l)}return"Scene Service"===s&&n.url&&(d=await(0,u.CD)(n,d,c)),(0,u.Q4)(d)>0?await m(e,p,d):await async function(e,a){const{portalItem:r}=e;if(!r?.url)return;const t=await(0,f.T)(r.url);t&&m(e,a,{layers:t.layers?.map(u.bS),tables:t.tables?.map(u.bS)})}(e,p)}(e,r)}(r,L,e);o&&r.read({url:o},L);const w=new l.L,h=await S(e,w,a);return h&&r.read(h,L),r.resourceReferences={portalItem:n,paths:L.readResourcePaths??[]},"subtype-group"!==r.type&&r.read({title:c},L),(0,p.y)(r,L)}(e,a)}async function m(e,a,r,t){let n=r.layers||[];const i=r.tables||[];if("Feature Collection"===e.portalItem?.type?(n.forEach(((e,a)=>{e.id=a,"Table"===e?.layerDefinition?.type&&i.push(e)})),n=n.filter((e=>"Table"!==e?.layerDefinition?.type))):(n.reverse(),i.reverse()),n.forEach((n=>{const i=t?.(n);if(i||!t){const t=w(e,a(n),r,n,i);e.add(t)}})),i.length){const a=await o.T.FeatureLayer();i.forEach((n=>{const i=t?.(n);if(i||!t){const t=w(e,a,r,n,i);e.tables.add(t)}}))}}function w(e,a,r,t,n){const i=e.portalItem,l={portalItem:i.clone(),layerId:t.id};null!=t.url&&(l.url=t.url);const s=new a(l);if("sourceJSON"in s&&(s.sourceJSON=n),"subtype-group"!==s.type&&(s.sublayerTitleMode="service-name"),"Feature Collection"===i.type){const e={origin:"portal-item",portal:i.portal||c.Z.getDefault()};s.read(t,e);const a=r.showLegend;null!=a&&s.read({showLegend:a},e)}return s}async function S(e,a,r){if(!1===e.supportsData)return;const t=e.instance,i=t.portalItem;if(!i)return;let l=null;try{l=await i.fetchData("json",r)}catch(e){}if(function(e){return"stream"!==e.type&&"layerId"in e}(t)){let e=null;const r=await async function(e,a,r){if(a?.layers&&a?.tables)return(0,u.Q4)(a);const t=(0,n.Qc)(e.url);if(!t)return 1;const i=await r.fetchServiceMetadata(t.url.path).catch((()=>null));return(a?.layers?.length??i?.layers?.length??0)+(a?.tables?.length??i?.tables?.length??0)}(i,l,a);if((l?.layers||l?.tables)&&r>0){if(null==t.layerId){const e=(0,u.XX)(l);t.layerId="subtype-group"===t.type?e?.[0]:(0,u.Ok)(l)}e=function(e,a){const{layerId:r}=a,t=e.layers?.find((e=>e.id===r))||e.tables?.find((e=>e.id===r));return t&&function(e,a){return!("feature"===a.type&&"layerType"in e&&"SubtypeGroupLayer"===e.layerType||"subtype-group"===a.type&&!("layerType"in e))}(t,a)?t:null}(l,t),e&&null!=l.showLegend&&(e.showLegend=l.showLegend)}return r>1&&"sublayerTitleMode"in t&&"service-name"!==t.sublayerTitleMode&&(t.sublayerTitleMode="item-title-and-service-name"),e}return l}},3072:(e,a,r)=>{r.d(a,{$O:()=>i,CD:()=>y,Ok:()=>l,Q4:()=>s,XX:()=>o,_Y:()=>c,bS:()=>n});var t=r(71592);function n(e){const a={id:e.id,name:e.name};return"Oriented Imagery Layer"===e.type&&(a.layerType="OrientedImageryLayer"),a}async function i(e,a,r){if(null==e?.layers||null==e?.tables){const t=await r.fetchServiceMetadata(a);(e=e||{}).layers=e.layers||t?.layers?.map(n),e.tables=e.tables||t?.tables?.map(n)}return e}function l(e){const a=e.layers;if(a?.length)return a[0].id;const r=e.tables;return r?.length?r[0].id:null}function s(e){return(e?.layers?.length??0)+(e?.tables?.length??0)}function o(e){const a=[];return e?.layers?.forEach((e=>{"SubtypeGroupLayer"===e.layerType&&a.push(e.id)})),a}function c(e){return e?.layers?.filter((({layerType:e})=>"OrientedImageryLayer"===e)).map((({id:e})=>e))}async function y(e,a,r){if(!e?.url)return a??{};if(a??={},!a.layers){const t=await r.fetchServiceMetadata(e.url);a.layers=t.layers?.map(n)}const{serverUrl:i,portalItem:l}=await(0,t.w)(e.url,{sceneLayerItem:e}).catch((()=>({serverUrl:null,portalItem:null})));if(null==i)return a.tables=[],a;if(!a.tables&&l){const e=await l.fetchData();if(e?.tables)a.tables=e.tables.map(n);else{const e=await r.fetchServiceMetadata(i);a.tables=e?.tables?.map(n)}}if(a.tables)for(const e of a.tables)e.url=`${i}/${e.id}`;return a}},28008:(e,a,r)=>{r.d(a,{fromItem:()=>u,v:()=>d});var t=r(20102),n=r(71592),i=r(7335),l=r(84230),s=r(87344),o=r(15235),c=r(3072),y=r(14661);async function u(e){!e.portalItem||e.portalItem instanceof o.default||(e={...e,portalItem:new o.default(e.portalItem)});const a=await async function(e){await e.load();const a=new i.L;return async function(e){const a=e.className,r=s.T[a];return{constructor:await r(),properties:e.properties}}(await d(e,a))}(e.portalItem);return new(0,a.constructor)({portalItem:e.portalItem,...a.properties})}async function d(e,a){switch(e.type){case"Map Service":return async function(e,a){return await async function(e,a){return(await a.fetchServiceMetadata(e.url)).tileInfo}(e,a)?{className:"TileLayer"}:{className:"MapImageLayer"}}(e,a);case"Feature Service":return async function(e,a){const r=await p(e,a);if("object"==typeof r){const e={};return null!=r.id&&(e.layerId=r.id),{className:r.className||"FeatureLayer",properties:e}}return{className:"GroupLayer"}}(e,a);case"Feature Collection":return async function(e){await e.load();const a=(0,y._$)(e,"Map Notes"),r=(0,y._$)(e,"Markup");if(a||r)return{className:"MapNotesLayer"};if((0,y._$)(e,"Route Layer"))return{className:"RouteLayer"};const t=await e.fetchData();return 1===(0,c.Q4)(t)?{className:"FeatureLayer"}:{className:"GroupLayer"}}(e);case"Scene Service":return async function(e,a){const r=await p(e,a,(async()=>{try{if(!e.url)return[];const{serverUrl:r}=await(0,n.w)(e.url,{sceneLayerItem:e}),t=await a.fetchServiceMetadata(r);return t?.tables??[]}catch{return[]}}));if("object"==typeof r){const t={};let n;if(null!=r.id?(t.layerId=r.id,n=`${e.url}/layers/${r.id}`):n=e.url,e.typeKeywords?.length)for(const a of Object.keys(l.fb))if(e.typeKeywords.includes(a))return{className:l.fb[a]};const i=await a.fetchServiceMetadata(n);return{className:l.fb[i?.layerType]||"SceneLayer",properties:t}}if(!1===r){const r=await a.fetchServiceMetadata(e.url);if("Voxel"===r?.layerType)return{className:"VoxelLayer"}}return{className:"GroupLayer"}}(e,a);case"Image Service":return async function(e,a){await e.load();const r=e.typeKeywords?.map((e=>e.toLowerCase()))??[];if(r.includes("elevation 3d layer"))return{className:"ElevationLayer"};if(r.includes("tiled imagery"))return{className:"ImageryTileLayer"};const t=await e.fetchData(),n=t?.layerType;if("ArcGISTiledImageServiceLayer"===n)return{className:"ImageryTileLayer"};if("ArcGISImageServiceLayer"===n)return{className:"ImageryLayer"};const i=await a.fetchServiceMetadata(e.url),l=i.cacheType?.toLowerCase(),s=i.capabilities?.toLowerCase().includes("tilesonly");return"map"===l||s?{className:"ImageryTileLayer"}:{className:"ImageryLayer"}}(e,a);case"Stream Service":case"Feed":return{className:"StreamLayer"};case"Vector Tile Service":return{className:"VectorTileLayer"};case"GeoJson":return{className:"GeoJSONLayer"};case"CSV":return{className:"CSVLayer"};case"KML":return{className:"KMLLayer"};case"WFS":return{className:"WFSLayer"};case"WMTS":return{className:"WMTSLayer"};case"WMS":return{className:"WMSLayer"};case"Group Layer":return{className:"GroupLayer"};default:throw new t.Z("portal:unknown-item-type","Unknown item type '${type}'",{type:e.type})}}async function p(e,a,r){const t=e.url;if(!t||/\/\d+$/.test(t))return{};await e.load();let n=await e.fetchData();if("Feature Service"===e.type){const e=await(0,c.$O)(n,t,a),r=f(e);if("object"==typeof r){const a=(0,c.XX)(e),t=(0,c._Y)(e);r.className=null!=r.id&&a.includes(r.id)?"SubtypeGroupLayer":null!=r.id&&t?.includes(r.id)?"OrientedImageryLayer":"FeatureLayer"}return r}if("Scene Service"===e.type&&(n=await(0,c.CD)(e,n,a)),(0,c.Q4)(n)>0)return f(n);const i=await a.fetchServiceMetadata(t);return r&&(i.tables=await r()),f(i)}function f(e){return 1===(0,c.Q4)(e)&&{id:(0,c.Ok)(e)}}},40555:(e,a,r)=>{r.d(a,{y:()=>l});var t=r(66643),n=r(95330),i=r(20941);async function l(e,a,r){const l=e&&e.getAtOrigin&&e.getAtOrigin("renderer",a.origin);if(l&&"unique-value"===l.type&&l.styleOrigin){const s=await(0,t.q6)(l.populateFromStyle());if((0,n.k_)(r),!1===s.ok){const r=s.error;a?.messages&&a.messages.push(new i.Z("renderer:style-reference",`Failed to create unique value renderer from style reference: ${r.message}`,{error:r,context:a})),e.clear("renderer",a?.origin)}}}},96187:(e,a,r)=>{r.d(a,{T:()=>n});var t=r(3172);async function n(e,a){const{data:r}=await(0,t.Z)(e,{responseType:"json",query:{f:"json",...a?.customParameters,token:a?.apiKey}});return r}}}]);
|