@arcgis/core 4.29.5 → 4.29.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{863d14c98737482f6788.js → 0700231efdaf7ce06d19.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{2146f7e55911da806aec.js → 2ca0fc695c66640a57dd.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{90b36361651839b1e3f0.js → 326aa2951f7e4da6d6b0.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{1251638c842dcf895ffe.js → 37133cf60bc9039a7407.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{de6d54df7ae32694fd70.js → 534abb4408b15ac778dd.js} +1 -1
  7. package/assets/esri/core/workers/chunks/967812e66fef41febb98.js +1 -0
  8. package/assets/esri/core/workers/chunks/{2621b755fa5403bd8a4c.js → e232f6fca5629ae66dcc.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{0e56ff6978ba8d9cf0c0.js → f74eec62bcf3264e2d90.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{8a9387483b19a5ec5b86.js → fc5ac713872766571e07.js} +1 -1
  11. package/assets/esri/themes/base/widgets/_LayerList.scss +2 -0
  12. package/assets/esri/themes/dark/main.css +1 -1
  13. package/assets/esri/themes/light/main.css +1 -1
  14. package/assets/esri/themes/light/view.css +1 -1
  15. package/core/workers/InvokeHandler.js +1 -1
  16. package/core/workers/RemoteClient.js +1 -1
  17. package/core/workers/utils.js +1 -1
  18. package/interfaces.d.ts +53 -35
  19. package/kernel.js +1 -1
  20. package/networks/UtilityNetwork.js +1 -1
  21. package/package.json +1 -1
  22. package/support/revision.js +1 -1
  23. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  24. package/views/2d/engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js +1 -1
  25. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  26. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/utils.js +1 -1
  27. package/views/2d/layers/features/FeatureContainer.js +1 -1
  28. package/views/2d/layers/features/PipelineConnectionHandlers.js +1 -1
  29. package/views/2d/layers/features/RenderState.js +1 -1
  30. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  31. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  32. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  33. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
  34. package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
  35. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  36. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  37. package/widgets/LayerList/support/layerListUtils.js +1 -1
  38. package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
  39. package/assets/esri/core/workers/chunks/5db9739e00f15613d1ea.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.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{QueryEngine as n}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as o}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as d}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as c}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as g}from"./strategies/PagedTileLoadStrategy.js";import{SnapshotLoadStrategy as m}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as _}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as l}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{UpdateTracking2D as y}from"../../support/UpdateTracking2D.js";class f{constructor(e,t,s,r){this._aggregateAdapter=e,this._subscriptions=t,this._onChange=s,this._connection=r,this._updateTracking=new y({debugName:"FeatureSource"}),this._store=new l(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new n({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:e.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._eventLog.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._eventLog.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}getOverride(e){return this._updateTracking.addPromise(this._doGetOverride(e))}applyOverride(e){this._store.applyOverrides(e)}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._metadata=new p(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&a(n,"availableFields")){if(await this._queryLastEditDateChanged())await this._updateStrategy(t);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(o){this._eventLog.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new d(this._connection))}async _doGetOverride(e){return this._strategy.queryOverride(e)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e=this.service,t="isSourceHosted"in e&&e.isSourceHosted,s=Array.isArray(e.source),r=e.source&&"collection"in e.source,a=t||s||r;if("stream"===this._schema.type){const e=new _(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}const i=u.fromSchema(this._schema,this._metadata),n=await this._supportSnapshotMode(this._schema,i);return n?new m(this._schema.service,i,this._store,n.featureCount,this.metadata,this._eventLog):a?new g(this._schema.service,i,this._store,this.metadata,this._eventLog):new c(this._schema.service,i,this._store,this.metadata,this._eventLog)}async _updateStrategy(e){const t=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._eventLog.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e.service,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.service.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await o(a,i.inner,{query:i.customParameters})).data.count,{min:h,max:u}=r.snapshotCountThresholds;return n<=h||r.supportsSnapshotMaxThreshold&&n<u?{featureCount:n}:null}}export{f as FeatureSource};
5
+ import e from"../../../../../request.js";import has from"../../../../../core/has.js";import{ignoreAbortErrors as t,throwIfNotAbortError as s}from"../../../../../core/promiseUtils.js";import{diff as r,hasRootDiffOnly as a,hasRootDiff as i}from"../../../../../core/accessorSupport/diffUtils.js";import{QueryEngine as n}from"../../../../../layers/graphics/data/QueryEngine.js";import{executeQueryForCount as o}from"../../../../../rest/query/operations/query.js";import{FeatureStoreStatistics as h}from"../FeatureStoreStatistics.js";import{FeatureSourceQueryInfo as u}from"./FeatureSourceQueryInfo.js";import{StreamMessenger as d}from"./StreamMessenger.js";import{DrillDownTileLoadStrategy as c}from"./strategies/DrillDownTileLoadStrategy.js";import{PagedTileLoadStrategy as g}from"./strategies/PagedTileLoadStrategy.js";import{SnapshotLoadStrategy as m}from"./strategies/SnapshotLoadStrategy.js";import{StreamLoadStrategy as _}from"./strategies/StreamLoadStrategy.js";import{FeatureSourceChunkStore as l}from"./strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as p}from"../support/FeatureMetadata.js";import{UpdateTracking2D as y}from"../../support/UpdateTracking2D.js";class f{constructor(e,t,s,r){this._aggregateAdapter=e,this._subscriptions=t,this._onChange=s,this._connection=r,this._updateTracking=new y({debugName:"FeatureSource"}),this._store=new l(this._onChange)}destroy(){this._strategy?.destroy(),this._store.destroy(),this._streamMessenger?.destroy()}get _eventLog(){return this._connection.eventLog}get metadata(){if(!this._metadata)throw new Error("InternalError: Metadata not defined. Was update called?");return this._metadata}get service(){return this._schema.service}get store(){return this._store}get streamMessenger(){return null==this._streamMessenger&&this._initStreamMessenger(),this._streamMessenger}get statistics(){return h.from(this._store)}get updateTracking(){return this._updateTracking}get queryEngine(){if(!this._queryEngine){if(!this._schema)return null;const{dataFilter:e}=this._schema.mutable,t=this._schema.mutable.availableFields,s=this._metadata;this._queryEngine=new n({featureStore:this._store,fieldsIndex:s.fieldsIndex,geometryType:s.geometryType,objectIdField:s.objectIdField,hasM:!1,hasZ:!1,spatialReference:e.outSpatialReference,cacheSpatialQueries:!0,aggregateAdapter:this._aggregateAdapter,timeInfo:s.timeInfo,definitionExpression:e.definitionExpression,availableFields:t})}return this._queryEngine}get isStream(){return"stream"===this._schema.type}chunks(){return Array.from(this._store.chunks())}cleanupRemovedChunks(){return this._store.cleanupRemovedChunks()}onSubscribe(e){this._eventLog.onEvent({type:"subscribe",tile:e.tile.id});const t=this._strategy?.load(e);t&&(t.then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))),this._updateTracking.addPromise(t))}onResume(e){this._updateTracking.addPromise(t(this._strategy?.load(e)))}onUnsubscribe(e){this._eventLog.onEvent({type:"unsubscribe",tile:e.tile.id}),this._strategy?.unload(e)}getOverride(e){return this._updateTracking.addPromise(this._doGetOverride(e))}applyOverride(e){this._store.applyOverrides(e,this.metadata)}async update(e,t){const s=e.source,n=r(this._schema?.mutable,s.mutable);if(!n)return!1;if(has("esri-2d-update-debug")&&console.debug(`Version[${t}] FeatureSource.update`,{changes:n}),this._schema=s,this._metadata=new p(this._schema.service.metadata),this._queryEngine?.destroy(),this._queryEngine=null,"feature"===this._schema.type&&null!=this._schema.service.queryMetadata.lastEditDate&&(this._lastEditDate=this._schema.service.queryMetadata.lastEditDate),null==this._streamMessenger&&"stream"===this._schema.type&&this._initStreamMessenger(),a(n,"sourceRefreshVersion")&&this._strategy?.refresh)return await this._strategy.refresh(),!0;if("feature"===s.type&&a(n,"availableFields")){if(await this._queryLastEditDateChanged())await this._updateStrategy(t);else{this._eventLog.onEvent({type:"updateFieldsStart"});try{await this._strategy.updateFields(s.mutable.availableFields),this._eventLog.onEvent({type:"updateFieldsEnd"})}catch(o){this._eventLog.onEvent({type:"updateFieldsError",error:o})}}return!1}return!(!i(n,"dataFilter")&&!i(n,"sourceRefreshVersion"))&&(await this._updateStrategy(t),!0)}_initStreamMessenger(){null==this._streamMessenger&&(this._streamMessenger=new d(this._connection))}async _doGetOverride(e){return this._strategy.queryOverride(e)}async _queryLastEditDateChanged(){if(null==this._lastEditDate)return!1;const t=this._schema.service.source,s={...t.query,f:"json"},r=(await e(t.path,{query:s,responseType:"json"})).data.editingInfo.lastEditDate;return r!==this._lastEditDate&&(this._lastEditDate=r,!0)}async _createStrategy(){const e=this.service,t="isSourceHosted"in e&&e.isSourceHosted,s=Array.isArray(e.source),r=e.source&&"collection"in e.source,a=t||s||r;if("stream"===this._schema.type){const e=new _(this._schema.service,this._schema.mutable.dataFilter,this._store,{outSR:this._schema.mutable.dataFilter.outSpatialReference},this.metadata);return this._streamMessenger.strategy=e,e}const i=u.fromSchema(this._schema,this._metadata),n=await this._supportSnapshotMode(this._schema,i);return n?new m(this._schema.service,i,this._store,n.featureCount,this.metadata,this._eventLog):a?new g(this._schema.service,i,this._store,this.metadata,this._eventLog):new c(this._schema.service,i,this._store,this.metadata,this._eventLog)}async _updateStrategy(e){const t=await this._createStrategy();this._eventLog.onEvent({type:"updateStrategyStart",about:t.about});const r=!!this._strategy;this._store.clear(),this._strategy?.destroy(),this._strategy=t,has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategy`,{strategy:t});const a=Array.from(this._subscriptions.values());if(!a.length)return void this._eventLog.onEvent({type:"updateStrategyEnd"});const i=Promise.all(a.map((e=>this._strategy.load(e).then((()=>this._eventLog.onEvent({type:"loaded",tile:e.tile.id}))).catch((t=>this._eventLog.onEvent({type:"error",tile:e.tile.id,error:t}))))));this._updateTracking.addPromise(i);try{r&&await i}catch(n){s(n)}this._eventLog.onEvent({type:"updateStrategyEnd"}),has("esri-2d-update-debug")&&console.debug(`Version[${e}] FeatureSource.updateStrategyEnd`,{strategy:t})}async _supportSnapshotMode(e,t){const{queryMetadata:s}=e.service,r=s.snapshotInfo;if(!r||!r.supportsSnapshotMinThreshold||!r.snapshotCountThresholds)return null;const a=e.service.source,i=t.createQuery();i.inner.orderByFields=[],i.inner.returnGeometry=!1;const n=(await o(a,i.inner,{query:i.customParameters})).data.count,{min:h,max:u}=r.snapshotCountThresholds;return n<=h||r.supportsSnapshotMaxThreshold&&n<u?{featureCount:n}:null}}export{f as FeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../core/Error.js";import t from"../../../../../../rest/support/Query.js";import{ALoadStrategy as r}from"./ALoadStrategy.js";import{createQueryAdapter as s}from"./support/queryAdapters.js";import{QueueProcessor as o}from"../../../../../support/QueueProcessor.js";class n extends r{constructor(e,t,r,n,a){super(r),this._serviceInfo=e,this._queryInfo=t,this._metadata=n,this._eventLog=a,this._queue=new o({concurrency:16,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters};return this._adapter.executeQuery(e.query.inner,t)}}),this._adapter=s(e,n)}async updateFields(r){this._queryInfo.updateFields(r);const s=Array.from(this._store.chunks()).map((async e=>{const r=t.fromJSON(e.queryInfo.queryJSON);if(r)try{return await this._tryUpdateFields(e.reader,r),null}catch(s){return s}})),o=(await Promise.all(s)).filter((e=>e));if(o.length)throw new e("featurelayer-query","Encountered errors when downloading fields",{errors:o})}async queryOverride({edits:e}){const t=[],r=[];for(const n of e.removed)null!=n.objectId&&-1!==n.objectId?t.push(n.objectId):r.push(n.globalId);r.length&&t.push(...this._mapGlobalIdsToObjectIds(r));const s=e.addOrModified.map((({objectId:e})=>e)),o=this._queryInfo.createQuery({objectIds:s});return{reader:await this._fetch(o),removed:t}}_mapGlobalIdsToObjectIds(e){const t=new Set(e),r=this._metadata.globalIdField;if(null==r)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const s=[];return this._store.forEachUnsafe((e=>{const o=e.readAttribute(r);t.has(o)&&s.push(e.getObjectId())})),s}async _fetch(e,t){const r=await this._enqueue(e,t);return await this._tryUpdateFields(r,e.inner),r}async _tryUpdateFields(e,t){const r=this._queryInfo.createPatchFieldsQuery(t,e.fields);if(!r)return;const s=await this._enqueue(r,this._options);e.joinAttributes(s)}async _enqueue(e,t){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}export{n as AFetchLoadStrategy};
5
+ import e from"../../../../../../core/Error.js";import t from"../../../../../../rest/support/Query.js";import{ALoadStrategy as r}from"./ALoadStrategy.js";import{createQueryAdapter as s}from"./support/queryAdapters.js";import{FeatureSetReaderJSON as o}from"../../support/FeatureSetReaderJSON.js";import{QueueProcessor as n}from"../../../../../support/QueueProcessor.js";class a extends r{constructor(e,t,r,o,a){super(r),this._serviceInfo=e,this._queryInfo=t,this._metadata=o,this._eventLog=a,this._queue=new n({concurrency:16,process:async e=>{const t={signal:e.options?.signal,query:e.query.customParameters};return this._adapter.executeQuery(e.query.inner,t)}}),this._adapter=s(e,o)}async updateFields(r){this._queryInfo.updateFields(r);const s=Array.from(this._store.chunks()).map((async e=>{const r=t.fromJSON(e.queryInfo.queryJSON);if(r)try{return await this._tryUpdateFields(e.reader,r),null}catch(s){return s}})),o=(await Promise.all(s)).filter((e=>e));if(o.length)throw new e("featurelayer-query","Encountered errors when downloading fields",{errors:o})}async queryOverride({edits:e}){const t=[],r=[];for(const o of e.removed)null!=o.objectId&&-1!==o.objectId?t.push(o.objectId):r.push(o.globalId);r.length&&t.push(...this._mapGlobalIdsToObjectIds(r));const s=e.addOrModified.map((({objectId:e})=>e));let n;if(s.length){const e=this._queryInfo.createQuery({objectIds:s});n=await this._fetch(e)}else n=o.empty(this._metadata);return{reader:n,removed:t}}_mapGlobalIdsToObjectIds(e){const t=new Set(e),r=this._metadata.globalIdField;if(null==r)throw new Error("InternalError: Recieved an edit with globalIds, but not supported by the service");const s=[];return this._store.forEachUnsafe((e=>{const o=e.readAttribute(r);t.has(o)&&s.push(e.getObjectId())})),s}async _fetch(e,t){const r=await this._enqueue(e,t);return await this._tryUpdateFields(r,e.inner),r}async _tryUpdateFields(e,t){const r=this._queryInfo.createPatchFieldsQuery(t,e.fields);if(!r)return;const s=await this._enqueue(r,this._options);e.joinAttributes(s)}async _enqueue(e,t){return this._eventLog.onEvent({type:"fetchStart"}),this._queue.push({query:e,options:t}).finally((()=>{this._eventLog.onEvent({type:"fetchEnd",done:0===this._queue.length})}))}}export{a as AFetchLoadStrategy};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as r}from"../../../support/FeatureSetReaderJSON.js";class t extends e{constructor(){super(...arguments),this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return r.fromOptimizedFeatures(this._features,this._layerSchema??{fields:[]})}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate(),this._layerSchema||(this._layerSchema=e.reader.fullSchema());const{reader:r,removed:t}=e,s=[],d=new Set,o=r.getCursor(),i=new Set(t);for(this.overridenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),r=e.objectId;s.push(e),d.add(r),this.overridenIds.add(r),this.removed.delete(r)}for(const a of this._features){const e=a.objectId;i.has(e)||d.has(e)||(s.push(a),this.overridenIds.add(e))}this._features=s;for(const a of d.values())this.removed.delete(a);for(const a of t)this.removed.add(a),this.overridenIds.add(a)}getTileReader(e){if(!this._features.length)return null;const r=this.queryFeaturesInBounds(e.bounds);return r.setTransformForDisplay(e.transform),r}}export{t as OverrideChunk};
5
+ import{ASourceChunk as e}from"./ASourceChunk.js";import{FeatureSetReaderJSON as r}from"../../../support/FeatureSetReaderJSON.js";class t extends e{constructor(e){super(),this.metadata=e,this.chunkId="override",this.normalizedChunkId="override",this.removed=new Set,this.overridenIds=new Set,this._features=[]}get reader(){return r.fromOptimizedFeatures(this._features,this.metadata)}get queryInfo(){return{}}get first(){return!1}get end(){return!1}get isTiled(){return!1}applyOverrides(e){super.invalidate();const{reader:r,removed:t}=e,s=[],d=new Set,o=r.getCursor(),i=new Set(t);for(this.overridenIds.clear();o.next();){const e=o.readOptimizedFeatureWorldSpace(),r=e.objectId;s.push(e),d.add(r),this.overridenIds.add(r),this.removed.delete(r)}for(const n of this._features){const e=n.objectId;i.has(e)||d.has(e)||(s.push(n),this.overridenIds.add(e))}this._features=s;for(const n of d.values())this.removed.delete(n);for(const n of t)this.removed.add(n),this.overridenIds.add(n)}getTileReader(e){if(!this._features.length)return null;const r=this.queryFeaturesInBounds(e.bounds);return r.setTransformForDisplay(e.transform),r}}export{t as OverrideChunk};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as r}from"./OverrideChunk.js";class t{constructor(s){this._onChange=s,this._chunks=new Map,this._overrideChunk=new r,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=new r}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyOverrides(e){this._overrideChunk.applyOverrides(e);for(const s of this._chunks.values())s.reader.removeIds(this._overrideChunk.overridenIds),s.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const r of this.chunks()){const t=r.queryFeaturesInBounds(e);for(;t.next();){const e=t.getObjectId();o.has(e)||(s(t.copy()),o.add(e))}}}forEachBounds(e,o){const r=s();for(const s of e){s.getBounds(r)&&o(r)}}}export{t as FeatureSourceChunkStore};
5
+ import e from"../../../../../../../core/Evented.js";import has from"../../../../../../../core/has.js";import{create as s}from"../../../../../../../geometry/support/aaBoundingBox.js";import{FeatureStoreQueryAdapter as o}from"../../../FeatureStoreQueryAdapter.js";import{OverrideChunk as r}from"./OverrideChunk.js";class n{constructor(s){this._onChange=s,this._chunks=new Map,this._chunksToRemove=[],this.events=new e,this.featureAdapter=new o}destroy(){this.clear()}clear(){for(const e of this._chunks.values())this._chunksToRemove.push(e);this._chunks.clear(),null!=this._overrideChunk&&this._chunksToRemove.push(this._overrideChunk),this._overrideChunk=null}*chunks(){this._overrideChunk&&(yield this._overrideChunk),yield*this._chunks.values()}insert(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.insert`),this._overrideChunk?.overridenIds.size&&e.reader.removeIds(this._overrideChunk.overridenIds),this._chunks.set(e.chunkId,e),this.events.emit("changed"),this._onChange()}remove(e){has("esri-2d-update-debug")&&console.debug(`Chunk[${e.chunkId}] SourceChunkStore.remove`),this._chunks.delete(e.chunkId),this._chunksToRemove.push(e)}cleanupRemovedChunks(){const e=this._chunksToRemove;return this._chunksToRemove=[],e}applyOverrides(e,s){null==this._overrideChunk&&(this._overrideChunk=new r(s)),this._overrideChunk.applyOverrides(e);for(const o of this._chunks.values())o.reader.removeIds(this._overrideChunk.overridenIds),o.invalidate()}forEach(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r.copy()),s.add(o))}}}forEachUnsafe(e){const s=new Set;for(const o of this.chunks()){const r=o.reader.getCursor();for(;r.next();){const o=r.getObjectId();s.has(o)||(e(r),s.add(o))}}}forEachInBounds(e,s){const o=new Set;for(const r of this.chunks()){const n=r.queryFeaturesInBounds(e);for(;n.next();){const e=n.getObjectId();o.has(e)||(s(n.copy()),o.add(e))}}}forEachBounds(e,o){const r=s();for(const s of e){s.getBounds(r)&&o(r)}}}export{n as FeatureSourceChunkStore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as C}from"../../../../symbols/support/utils.js";import w from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as O}from"./constants.js";import{perObjectElevationAligner as j}from"./ElevationAligners.js";import{SymbolUpdateType as I,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as L}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as G}from"./placementUtils.js";import{placePointOnGeometry as V,createStageObject as H,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as B,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as W,ConvertOptions as $}from"../support/FastSymbolUpdates.js";import{createTexture as q,requiresHalfTexelOffset as J,defaultSymbolSizeRatio as Z,defaultTexSize as K}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Q}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";const re=f(0,0,1),ie=16,se=1.5,oe=Z,ae=[oe/2,oe/2,1-oe/2,1-oe/2],ne=[K*oe,K*oe];class le extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=C(this.symbolLayer),i=u(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ie);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l&&l.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new M({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",a),i=new ee(s,{width:s?.width??1,height:s?.height??1})}else i=new ee(new ImageData(1,1),{width:1,height:1});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ce(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(he(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>q(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=J(t),e.distanceFieldBoundingBox=ae;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/oe,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=this._computeSizeFromTexture(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=w(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=he(this._getPrimitive())?se:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(he(this._getPrimitive()))return O;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in G?G[e]:G.center}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new te(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=B(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new te(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage),i=[e.parameters.width,e.parameters.height]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(le.elevationModeChangeTypes,r,i);if(s!==I.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return L.RecreateSymbol;if(!N(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return L.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return L.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m)return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=this._computeSizeFromTexture(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return me}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=X(r,re,null,i,s,ue,null,n,c),m=H(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,j,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),k(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Q;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=X(r,re,a,i,s,null,null,l,c),m=new Y(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=W(de,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new $({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}_computeSizeFromTexture({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}test(){return{...super.test(),material:this._materials[0]}}}function ce(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function he(e){return null!=e&&("cross"===e||"x"===e)}le.PRIMITIVE_SIZE=ne,le.elevationModeChangeTypes={definedChanged:I.UPDATE,staysOnTheGround:I.NONE,onTheGroundChanged:I.RECREATE};const me={mode:"relative-to-ground",offset:0},ue=y(0,0,0,1),de=_();export{le as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as m}from"../../../../core/string.js";import{dataComponents as u}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as _,fromValues as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as g}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as x}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as b}from"../../../../support/arcadeOnDemand.js";import{CIMSymbolHelper as S}from"../../../../symbols/cim/CIMSymbolHelper.js";import{OverrideHelper as v}from"../../../../symbols/cim/OverrideHelper.js";import{evaluateValueOrFunction as P}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as z}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as R}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as M}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as C}from"../../../../symbols/support/utils.js";import w from"../../../2d/arcade/callExpressionWithFeature.js";import{transparentUnit as I}from"./constants.js";import{perObjectElevationAligner as O}from"./ElevationAligners.js";import{SymbolUpdateType as j,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as U}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as L}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as G}from"./placementUtils.js";import{placePointOnGeometry as V,createStageObject as H,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as B,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as W,ConvertOptions as $}from"../support/FastSymbolUpdates.js";import{createTexture as q,requiresHalfTexelOffset as J,defaultSymbolSizeRatio as Z,defaultTexSize as K}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as Q}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";const re=f(0,0,1),ie=16,se=1.5,oe=Z,ae=[oe/2,oe/2,1-oe/2,1-oe/2],ne=[K*oe,K*oe];class le extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=C(this.symbolLayer),i=this._getCIMResource(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_getCIMResource(e){const t=u(e);return"application/json"===t?.mediaType?t.data:void 0}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):ie);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){let t=this._cimData;if(t&&t.symbol||this.logger.error("Can't create texture, CIM data is undefined"),t.primitiveOverrides){t=s(t);const r=t.primitiveOverrides;v.evaluateOverrides(r,e,this._arcadeInfo.geometryType,null,null),v.applyOverrides(t.symbol,r)}const r=m(JSON.stringify(t));let i=this._cimSymbolTextures.get(r);if(i)return i;const o=this._context.sharedResources.cimSymbolRasterizer,a=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;a&&v.applyDictionaryTextOverrides(t.symbol,e,a,null);const n=null!=this._cimScaleFactorOrFunction?P(this._cimScaleFactorOrFunction,e):1;1!==n&&t.symbol&&z(t.symbol,n,!0);const l=S.getEnvelope(t,null,o.resourceManager);if(l&&l.width&&l.height){const e=l.x+l.width/2,r=l.y+l.height/2,s=o.rasterize({type:"cim",data:t},l.width,l.height,e,r,1,"esriGeometryPoint"),a=new M({x:-l.x/l.width-.5,y:(l.height+l.y)/l.height-.5});this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",a),i=new ee(s,{width:s?.width??1,height:s?.height??1})}else i=new ee(new ImageData(1,1),{width:1,height:1});return this._cimSymbolTextures.set(r,i),this._context.stage.add(i),i}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ce(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:c(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(he(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>q(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=J(t),e.distanceFieldBoundingBox=ae;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/oe,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=this._computeSizeFromTexture(c,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){if(this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference))}const i=this._context.sharedResources.cimSymbolRasterizer,s=[],o=t,a=o?.symbol;S.fetchResources(a,i.resourceManager,s,r),S.fetchFonts(a,i.resourceManager,s);const n=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):[],c=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:c,fields:n,geometryType:"esriGeometryPoint"},o?.primitiveOverrides&&s.push(v.createRenderExpressions(o.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await b(t,this._context.layer.spatialReference,n);this._cimScaleFactorOrFunction=(e,t,i)=>{const s=w(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||R}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=he(this._getPrimitive())?se:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(he(this._getPrimitive()))return I;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in G?G[e]:G.center}_createMaterialAndAddToStage(e,t){if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new te(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=B(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new te(e),t.add(this._materials[0]),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._forEachMaterial((e=>this._context.stage.remove(e))),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=c(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimData){if(!this._cimData.symbol)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage);const o=window.devicePixelRatio||1;i=[e.parameters.width/o,e.parameters.height/o]}else i=this._size,r=this._materials[0];const s=V(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,a=this._getVertexOpacityAndColor(o);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(o,e)}n*=this._symbolTextureRatio;const l=d(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,a,l,e.layer.uid):this._createAs3DShape(t,s,r,a,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(le.elevationModeChangeTypes,r,i);if(s!==j.UPDATE)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return L.RecreateSymbol;if(!N(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return L.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return L.FastUpdate}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:m}=this._context.sharedResources;if(null==h||null==m||null!=this._getCIMResource(h))return;const u=this._getIconSize(),d=u*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push((()=>{this._patchTask=o(this._patchTask),this._patchTask=r((e=>this._context.schedule((async(e,r)=>{const s=await t(m.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial((e=>{e.visible=!1,e.setParameters({textureId:null})}));const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=this._computeSizeFromTexture(c,u),this._forEachMaterial((e=>{e.setParameters({textureId:c.id}),e.visible=!0}))}),e)))})),delete c.href}_defaultElevationInfoNoZ(){return me}_createAs3DShape(e,t,r,i,s,o,a){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:l}),h=X(r,re,null,i,s,ue,null,n,c),m=H(this._context,t,h,o,a);if(null==m)return null;const u=new D(this,m.object,[h],null,null,O,o);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),k(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=_();g(t,a,this._context.overlaySR),a[2]=Q;const n=this._context.clippingExtent;if(null!=n&&!x(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=X(r,re,a,i,s,null,null,l,c),m=new Y(h,{layerUid:o,graphicUid:e.uid}),u=new U(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=W(de,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=f(e,e,e),r=h(1),i=e*r,s=f(i,i,i);return new $({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}_computeSizeFromTexture({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}test(){return{...super.test(),material:this._materials[0]}}}function ce(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function he(e){return null!=e&&("cross"===e||"x"===e)}le.PRIMITIVE_SIZE=ne,le.elevationModeChangeTypes={definedChanged:j.UPDATE,staysOnTheGround:j.NONE,onTheGroundChanged:j.RECREATE};const me={mode:"relative-to-ground",offset:0},ue=y(0,0,0,1),de=_();export{le as Graphics3DIconSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- const n={hide:"hide",hideChildren:"hide-children"},i="root",e=10,t=2;function r({exclusive:n,visible:i,visibilityAppearance:e}){const t="checkbox"===e;return i?n?"circle-f":t?"check-square-f":"view-visible":n?"circle":t?"square":"view-hide"}function l({connectionStatus:n,publishing:i}){return n?"connected"===n?"beacon":"offline":i?"stop-square":"bullet-point"}function u(i){return!!i&&i.listMode===n.hideChildren}function a(n){if(n)return null!=n.listMode?n.listMode:void 0}function o(n){return null!=n&&"minScale"in n&&null!=n.minScale?n.minScale:void 0}function s(n){return null!=n&&"maxScale"in n&&null!=n.maxScale?n.maxScale:void 0}function c(n){if(!n)return"inherited";const i=S(x(n)?n.layer:n);return null!=i?i?"independent":"inherited":"visibilityMode"in n&&null!=n.visibilityMode?n.visibilityMode:"independent"}function d(n){if(!(!n||"type"in n&&"wmts"===n.type||u(n)))return"sublayers"in n?"sublayers":"layers"in n?"layers":void 0}function y(n){const i=(n?.layer&&x(n.layer)?n.layer.layer:void 0)??n?.layer;return!!i&&(M(i)??!0)}function f(i){return a(i)!==n.hide}function p(n,i){if(!n||null==i||isNaN(i))return!1;const e=o(n),t=s(n),r=null!=e&&!isNaN(e)&&e>0&&i>e,l=null!=t&&!isNaN(t)&&t>0&&i<t;return r||l}function b(n,i){n?.sort(((n,e)=>{const t="uid"in n?i.indexOf(n.uid):-1,r="uid"in e?i.indexOf(e.uid):-1;return t>r?-1:t<r?1:0}))}function h(n,i){const e=n?.layer;if(!e)return;const t=d(e);if(!t)return;let r;"layers"===t&&"layers"in e?r=e.layers:"sublayers"===t&&"sublayers"in e&&(r=e.sublayers),b(r,i)}function v(n){const i=n?.layer;return i&&"layers"in i?i.layers:null}function m(n){const i=x(n)?n:null,e=n?.parent,t=null!=e&&"type"in e&&"map-image"===e.type?i?.source:null,r="";return t&&e?{layer:e,title:r,sublayerIds:[t.mapLayerId]}:{layer:n,title:r}}function x(n){return null!=n&&"layer"in n&&null!=n.layer}function S(n){const i=N(n);return null!=i&&"supportsSublayerVisibility"in i?i.supportsSublayerVisibility:void 0}function M(n){const i=N(n);return null!=i&&"supportsDynamicLayers"in i?i.supportsDynamicLayers:void 0}function N(n){return n&&"capabilities"in n&&null!=n.capabilities&&"exportMap"in n.capabilities?n.capabilities.exportMap:void 0}function g(n){return n?.["data-item"]}function q(n){return n?.getAttribute("data-layer-type")}function w({children:n,error:i,incompatible:e}){return!!n?.filter((n=>!n.hidden)).length&&!i&&!e}export{u as areChildrenHidden,f as canDisplayLayer,y as canSortSublayers,a as findLayerListMode,s as findLayerMaxScale,o as findLayerMinScale,c as findLayerVisibilityMode,g as getItem,v as getItemLayers,q as getLayerType,m as getLegendLayerInfo,d as getNormalizedChildLayerProperty,l as getStatusIcon,r as getVisibilityIcon,p as isLayerOutsideScaleRange,x as isSublayer,w as listItemHasChildren,t as minDragEnabledItems,e as minFilterItems,h as sortChildLayersToIds,b as sortLayersToIds,i as sortableRoot};
5
+ const n={hide:"hide",hideChildren:"hide-children"},i="root",e=10,t=2;function r({exclusive:n,visible:i,visibilityAppearance:e}){const t="checkbox"===e;return i?n?"circle-f":t?"check-square-f":"view-visible":n?"circle":t?"square":"view-hide"}function l({connectionStatus:n,publishing:i}){return n?"connected"===n?"beacon":"offline":i?"square":"bullet-point"}function u(i){return!!i&&i.listMode===n.hideChildren}function a(n){if(n)return null!=n.listMode?n.listMode:void 0}function o(n){return null!=n&&"minScale"in n&&null!=n.minScale?n.minScale:void 0}function s(n){return null!=n&&"maxScale"in n&&null!=n.maxScale?n.maxScale:void 0}function c(n){if(!n)return"inherited";const i=S(x(n)?n.layer:n);return null!=i?i?"independent":"inherited":"visibilityMode"in n&&null!=n.visibilityMode?n.visibilityMode:"independent"}function d(n){if(!(!n||"type"in n&&"wmts"===n.type||u(n)))return"sublayers"in n?"sublayers":"layers"in n?"layers":void 0}function y(n){const i=(n?.layer&&x(n.layer)?n.layer.layer:void 0)??n?.layer;return!!i&&(M(i)??!0)}function f(i){return a(i)!==n.hide}function p(n,i){if(!n||null==i||isNaN(i))return!1;const e=o(n),t=s(n),r=null!=e&&!isNaN(e)&&e>0&&i>e,l=null!=t&&!isNaN(t)&&t>0&&i<t;return r||l}function b(n,i){n?.sort(((n,e)=>{const t="uid"in n?i.indexOf(n.uid):-1,r="uid"in e?i.indexOf(e.uid):-1;return t>r?-1:t<r?1:0}))}function h(n,i){const e=n?.layer;if(!e)return;const t=d(e);if(!t)return;let r;"layers"===t&&"layers"in e?r=e.layers:"sublayers"===t&&"sublayers"in e&&(r=e.sublayers),b(r,i)}function v(n){const i=n?.layer;return i&&"layers"in i?i.layers:null}function m(n){const i=x(n)?n:null,e=n?.parent,t=null!=e&&"type"in e&&"map-image"===e.type?i?.source:null,r="";return t&&e?{layer:e,title:r,sublayerIds:[t.mapLayerId]}:{layer:n,title:r}}function x(n){return null!=n&&"layer"in n&&null!=n.layer}function S(n){const i=N(n);return null!=i&&"supportsSublayerVisibility"in i?i.supportsSublayerVisibility:void 0}function M(n){const i=N(n);return null!=i&&"supportsDynamicLayers"in i?i.supportsDynamicLayers:void 0}function N(n){return n&&"capabilities"in n&&null!=n.capabilities&&"exportMap"in n.capabilities?n.capabilities.exportMap:void 0}function g(n){return n?.["data-item"]}function q(n){return n?.getAttribute("data-layer-type")}function w({children:n,error:i,incompatible:e}){return!!n?.filter((n=>!n.hidden)).length&&!i&&!e}export{u as areChildrenHidden,f as canDisplayLayer,y as canSortSublayers,a as findLayerListMode,s as findLayerMaxScale,o as findLayerMinScale,c as findLayerVisibilityMode,g as getItem,v as getItemLayers,q as getLayerType,m as getLegendLayerInfo,d as getNormalizedChildLayerProperty,l as getStatusIcon,r as getVisibilityIcon,p as isLayerOutsideScaleRange,x as isSublayer,w as listItemHasChildren,t as minDragEnabledItems,e as minFilterItems,h as sortChildLayersToIds,b as sortLayersToIds,i as sortableRoot};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.29/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import i from"../../core/Error.js";import t from"../../core/Logger.js";import{watch as o,initial as s}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import c from"../../portal/Portal.js";import{hasUserTypeExtension as l}from"../../portal/support/utils.js";import{createFeatureServices as h}from"../../rest/featureService/utils.js";import u from"../../versionManagement/VersionManagementService.js";let g=class extends r{constructor(e){super(e),this._currentVersionIdentifiers=new Map,this._initialValidationsFinished=!1,this._portals=new Map,this._updatingHandles=new d,this._validConstructProperties=!0,this.advancedEditingUserTypeExtensionForUrl=new Map,this.executionError=void 0,this.featureServices=new Map,this.layers=null,this.loadError=void 0,this.serverVersionForUrl=new Map,this.serviceNames=new Map,this.userForUrl=new Map,this.versionInfos=new Map,this.versionManagementServices=new Map}initialize(){this.addHandles([o((()=>this.layers?.toArray()),(async()=>{await this._onLayersChange()}),s)])}destroy(){this._updatingHandles.destroy()}get state(){return this.loadError||!this._validConstructProperties?"disabled":this.executionError?"failed":this._updatingHandles.updating?"executing":this._initialValidationsFinished?"ready":"loading"}async alterVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=this.versionManagementServices.get(e.featureServerUrl);if(!r)return void this._logNoVersionManagementServiceFoundError();if(!this.serverVersionForUrl.has(e.featureServerUrl)||this.serverVersionForUrl.get(e.featureServerUrl)<=11.1)return void this._logError("execution-error","no-valid-enterprise-version");if(!this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const{featureServerUrl:i,versionIdentifier:t,...o}=e;await r.alterVersion(t,o).catch((async e=>{await this.getVersionInfos(i,!0),this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async changeVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();const o=this._currentVersionIdentifiers.get(e)??{name:t.defaultVersionIdentifier.name,guid:t.defaultVersionIdentifier.guid},s={name:r,guid:i};await t.changeVersion(this.featureServices.get(e)?.layers,o,s).catch((e=>{this._logExecutionError(e)}))&&this._currentVersionIdentifiers.set(e,s)})()):this._logError("load-error",this.loadError)}async createVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=e.featureServerUrl,i=this.versionManagementServices.get(r);if(!i)return void this._logNoVersionManagementServiceFoundError();const t=this.advancedEditingUserTypeExtensionForUrl.get(e.featureServerUrl),o=this.userForUrl.get(r).toUpperCase(),s=this._isEmptyString(e.ownerName)?o:e.ownerName?.trim().toUpperCase();if(s!==o){if(this.serverVersionForUrl.get(r)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!t)return void this._logError("execution-error","no-advanced-editing-user-type-extension")}if("SDE"===s?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase()||this.versionInfos.get(r)?.find((r=>r.versionIdentifier.name.toUpperCase()===(s+"."+e.versionName).toUpperCase()||r.versionIdentifier.name.toUpperCase()===(o+"."+e.versionName).toUpperCase())))return void this._logError("execution-error","no-valid-version-name");const n=await i.createVersion({versionName:e.versionName,access:s!==o?"public":e.access,description:e.description}).catch((e=>{this._logExecutionError(e)}));if(!this.executionError&&s!==o){const{guid:i,name:t}=n.versionIdentifier,a={featureServerUrl:r,versionIdentifier:{guid:i,name:t},access:e.access,ownerName:s};await this.alterVersion(a),this.executionError&&this.deleteVersion(r,o+"."+e.versionName,n.versionIdentifier.guid)}await this.getVersionInfos(r,!0)})()):this._logError("load-error",this.loadError)}async deleteVersion(e,r,i){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const t=this.versionManagementServices.get(e);if(!t)return void this._logNoVersionManagementServiceFoundError();if(this.serverVersionForUrl.get(e)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!this.advancedEditingUserTypeExtensionForUrl.get(e))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const o={name:r,guid:i};await t.deleteVersion(o).catch((e=>{this._logExecutionError(e)}))&&await this.getVersionInfos(e,!0).catch((e=>{this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async getVersionInfos(e,r){if("disabled"!==this.state)return await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const i=this.featureServices.get(e)?.featureService;if(!i)return void this._logError("execution-error","no-feature-service-found");if(!i.loaded){await i.load().catch((e=>{this._logExecutionError(e)}));const r=i.url;this.serverVersionForUrl.set(r,i.sourceJSON?.currentVersion??0),this.serverVersionForUrl.get(r)<=11.1&&this.advancedEditingUserTypeExtensionForUrl.set(r,!1);const t=this.userForUrl.get(e);this._portals.get(e)&&t?this.advancedEditingUserTypeExtensionForUrl.set(r,await l(this._portals.get(e),t,"advediting")):this.advancedEditingUserTypeExtensionForUrl.set(r,!1)}i.versionManagementServiceUrl&&this.versionManagementServices.set(i.url,new u({url:i.versionManagementServiceUrl}));const t=this.versionManagementServices.get(e);if(t){if(t.loaded||await t.load().catch((e=>{this._logExecutionError(e)})),!this.versionInfos.get(e)||r){const r=await t.getVersionInfos().catch((e=>{this._logExecutionError(e)}));this.versionInfos.set(e,r),this._currentVersionIdentifiers.set(e,t.defaultVersionIdentifier)}}else this._logNoVersionManagementServiceFoundError()})()),this.versionInfos.get(e);this._logError("load-error",this.loadError)}_isEmptyString(e){return!e||0===e.trim().length}_logError(e,r){switch(e){case"load-error":this._setLoadError(r),t.getLogger(this).error(new i(e,r));break;case"execution-error":this._setExecutionError(r),t.getLogger(this).error(new i(e,r))}}_logExecutionError(e){this._logError("execution-error",e.message)}_logNoVersionManagementServiceFoundError(){this._logError("execution-error","no-version-management-service-found")}async _onLayersChange(){if(this._initialValidationsFinished=!1,this._setLoadError(),this._validConstructProperties=!0,!this.layers)return this._logError("load-error","no-layers-property"),void(this._validConstructProperties=!1);if(this.featureServices=h(this.layers),!this.featureServices.size)return this._logError("load-error","no-feature-services"),void(this._validConstructProperties=!1);for(const e of this.featureServices.keys())if(!this.serviceNames.has(e)){this.serviceNames.set(e,e.split("/").at(-2));const r=new c({authMode:"immediate",url:new URL(e).origin+"/portal"});await r.load(),this._portals.set(e,r);const i=r?.user?.username;i&&this.userForUrl.set(e,i)}this._initialValidationsFinished=!0}_setExecutionError(e){this._set("executionError",e)}_setLoadError(e){this._set("loadError",e)}};e([n()],g.prototype,"_initialValidationsFinished",void 0),e([n({readOnly:!0})],g.prototype,"advancedEditingUserTypeExtensionForUrl",void 0),e([n({readOnly:!0})],g.prototype,"executionError",void 0),e([n()],g.prototype,"featureServices",void 0),e([n()],g.prototype,"layers",void 0),e([n({readOnly:!0})],g.prototype,"loadError",void 0),e([n({readOnly:!0})],g.prototype,"serverVersionForUrl",void 0),e([n()],g.prototype,"serviceNames",void 0),e([n({readOnly:!0})],g.prototype,"state",null),e([n({readOnly:!0})],g.prototype,"userForUrl",void 0),e([n()],g.prototype,"versionInfos",void 0),e([n()],g.prototype,"versionManagementServices",void 0),g=e([a("esri.widgets.VersionManagement.VersionManagementViewModel")],g);const v=g;export{v as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import o from"../../core/Error.js";import i from"../../core/Logger.js";import{watch as t,initial as s}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import u from"../../portal/Portal.js";import{hasUserTypeExtension as p}from"../../portal/support/utils.js";import{createFeatureServices as c}from"../../rest/featureService/utils.js";import h from"../../versionManagement/VersionManagementService.js";let l=class extends r{constructor(e){super(e),this._initialValidationsFinished=!1,this._portalLookup=new Map,this._updatingHandles=new d,this._validConstructProperties=!0,this.advancedEditingUserTypeExtensionLookup=new Map,this.executionError=void 0,this.featureServiceLookup=new Map,this.loadError=void 0,this.serverVersionLookup=new Map,this.serviceNameLookup=new Map,this.userLookup=new Map,this.versionIdentifierLookup=new Map,this.versionInfoLookup=new Map,this.versionManagementServiceLookup=new Map}initialize(){this.addHandles([t((()=>this.view?.map.layers.toArray()),(async()=>{await this._onLayersChange()}),s)])}destroy(){this._updatingHandles.destroy()}get state(){return this.loadError||!this._validConstructProperties?"disabled":this.executionError?"failed":this._updatingHandles.updating?"executing":this._initialValidationsFinished?"ready":"loading"}set view(e){this._get("view")!==e&&this._set("view",e)}async alterVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=this.versionManagementServiceLookup.get(e.featureServerUrl);if(!r)return void this._logNoVersionManagementServiceFoundError();if(!this.serverVersionLookup.has(e.featureServerUrl)||this.serverVersionLookup.get(e.featureServerUrl)<=11.1)return void this._logError("execution-error","no-valid-enterprise-version");if(!this.advancedEditingUserTypeExtensionLookup.get(e.featureServerUrl))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const{featureServerUrl:o,versionIdentifier:i,...t}=e;await r.alterVersion(i,t).catch((async e=>{await this.getVersionInfos(o,!0),this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async changeVersion(e,r,o){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const i=this.versionManagementServiceLookup.get(e);if(!i)return void this._logNoVersionManagementServiceFoundError();const t=this.versionIdentifierLookup.get(e)??{name:i.defaultVersionIdentifier.name,guid:i.defaultVersionIdentifier.guid},s={name:r,guid:o};await i.changeVersion(this.view?.map,t,s).catch((e=>{this._logExecutionError(e)}))&&this.versionIdentifierLookup.set(e,s)})()):this._logError("load-error",this.loadError)}async createVersion(e){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const r=e.featureServerUrl,o=this.versionManagementServiceLookup.get(r);if(!o)return void this._logNoVersionManagementServiceFoundError();const i=this.advancedEditingUserTypeExtensionLookup.get(e.featureServerUrl),t=this.userLookup.get(r).toUpperCase(),s=this._isEmptyString(e.ownerName)?t:e.ownerName?.trim().toUpperCase();if(s!==t){if(this.serverVersionLookup.get(r)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!i)return void this._logError("execution-error","no-advanced-editing-user-type-extension")}if("SDE"===s?.toUpperCase()&&"DEFAULT"===e.versionName.toUpperCase()||this.versionInfoLookup.get(r)?.find((r=>r.versionIdentifier.name.toUpperCase()===(s+"."+e.versionName).toUpperCase()||r.versionIdentifier.name.toUpperCase()===(t+"."+e.versionName).toUpperCase())))return void this._logError("execution-error","no-valid-version-name");const n=await o.createVersion({versionName:e.versionName,access:s!==t?"public":e.access,description:e.description}).catch((e=>{this._logExecutionError(e)}));if(!this.executionError&&s!==t){const{guid:o,name:i}=n.versionIdentifier,a={featureServerUrl:r,versionIdentifier:{guid:o,name:i},access:e.access,ownerName:s};await this.alterVersion(a),this.executionError&&this.deleteVersion(r,t+"."+e.versionName,n.versionIdentifier.guid)}await this.getVersionInfos(r,!0)})()):this._logError("load-error",this.loadError)}async deleteVersion(e,r,o){"disabled"!==this.state?await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const i=this.versionManagementServiceLookup.get(e);if(!i)return void this._logNoVersionManagementServiceFoundError();if(this.serverVersionLookup.get(e)<=11.1)return void this._logError("execution-error","versioning-api-error");if(!this.advancedEditingUserTypeExtensionLookup.get(e))return void this._logError("execution-error","no-advanced-editing-user-type-extension");const t={name:r,guid:o};await i.deleteVersion(t).catch((e=>{this._logExecutionError(e)}))&&await this.getVersionInfos(e,!0).catch((e=>{this._logExecutionError(e)}))})()):this._logError("load-error",this.loadError)}async getVersionInfos(e,r){if("disabled"!==this.state)return await this._updatingHandles.addPromise((async()=>{this._setExecutionError();const o=this.featureServiceLookup.get(e)?.featureService;if(!o)return void this._logError("execution-error","no-feature-service-found");if(!o.loaded){await o.load().catch((e=>{this._logExecutionError(e)}));const r=o.url;this.serverVersionLookup.set(r,o.sourceJSON?.currentVersion??0),this.serverVersionLookup.get(r)<=11.1&&this.advancedEditingUserTypeExtensionLookup.set(r,!1);const i=this.userLookup.get(e);this._portalLookup.get(e)&&i?this.advancedEditingUserTypeExtensionLookup.set(r,await p(this._portalLookup.get(e),i,"advediting")):this.advancedEditingUserTypeExtensionLookup.set(r,!1)}o.versionManagementServiceUrl&&this.versionManagementServiceLookup.set(o.url,new h({url:o.versionManagementServiceUrl}));const i=this.versionManagementServiceLookup.get(e);if(i){if(i.loaded||await i.load().catch((e=>{this._logExecutionError(e)})),!this.versionInfoLookup.get(e)||r){const r=await i.getVersionInfos().catch((e=>{this._logExecutionError(e)}));this.versionInfoLookup.set(e,r)}}else this._logNoVersionManagementServiceFoundError()})()),this.versionInfoLookup.get(e);this._logError("load-error",this.loadError)}_isEmptyString(e){return!e||0===e.trim().length}_logError(e,r){switch(e){case"load-error":this._setLoadError(r),i.getLogger(this).error(new o(e,r));break;case"execution-error":this._setExecutionError(r),i.getLogger(this).error(new o(e,r))}}_logExecutionError(e){this._logError("execution-error",e.message)}_logNoVersionManagementServiceFoundError(){this._logError("execution-error","no-version-management-service-found")}async _onLayersChange(){if(this._initialValidationsFinished=!1,this._setLoadError(),this._validConstructProperties=!0,!this.view)return this._logError("load-error","no-view-property"),void(this._validConstructProperties=!1);if(this.featureServiceLookup=c(this.view.map.layers),!this.featureServiceLookup.size)return this._logError("load-error","no-feature-services"),void(this._validConstructProperties=!1);for(const e of this.featureServiceLookup.keys())if(!this.serviceNameLookup.has(e)){this.serviceNameLookup.set(e,e.split("/").at(-2));const r=new u({authMode:"immediate",url:new URL(e).origin+"/portal"});await r.load(),this._portalLookup.set(e,r);const o=r?.user?.username;o&&this.userLookup.set(e,o)}this._initialValidationsFinished=!0}_setExecutionError(e){this._set("executionError",e)}_setLoadError(e){this._set("loadError",e)}};e([n()],l.prototype,"_initialValidationsFinished",void 0),e([n({readOnly:!0})],l.prototype,"advancedEditingUserTypeExtensionLookup",void 0),e([n({readOnly:!0})],l.prototype,"executionError",void 0),e([n()],l.prototype,"featureServiceLookup",void 0),e([n({readOnly:!0})],l.prototype,"loadError",void 0),e([n({readOnly:!0})],l.prototype,"serverVersionLookup",void 0),e([n()],l.prototype,"serviceNameLookup",void 0),e([n({readOnly:!0})],l.prototype,"state",null),e([n({readOnly:!0})],l.prototype,"userLookup",void 0),e([n({readOnly:!0})],l.prototype,"versionIdentifierLookup",void 0),e([n()],l.prototype,"versionInfoLookup",void 0),e([n()],l.prototype,"versionManagementServiceLookup",void 0),e([n()],l.prototype,"view",null),l=e([a("esri.widgets.VersionManagement.VersionManagementViewModel")],l);const v=l;export{v as default};