@arcgis/core 4.21.0-next.20210919 → 4.21.0

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/config.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.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"./core/global.js";import"./core/has.js";import{deepMerge as r}from"./core/object.js";import{buildDate as s}from"./support/revision.js";const t={apiKey:void 0,applicationUrl:e.location&&e.location.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryService:null,geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(e.esriConfig&&(r(t,e.esriConfig,!0),delete t.has),!t.assetsPath){const e="4.21.0";t.assetsPath=`https://cdn.jsdelivr.net/npm/@arcgis/core@${e}-next.${s}/assets`}t.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(t,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),t.request.corsEnabledServers=[],t.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{t as default};
5
+ import e from"./core/global.js";import"./core/has.js";import{deepMerge as r}from"./core/object.js";const s={apiKey:void 0,applicationUrl:e.location&&e.location.href,assetsPath:"",fontsUrl:"https://static.arcgis.com/fonts",geometryService:null,geometryServiceUrl:"https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer",geoRSSServiceUrl:"https://utility.arcgis.com/sharing/rss",kmlServiceUrl:"https://utility.arcgis.com/sharing/kml",portalUrl:"https://www.arcgis.com",workers:{loaderConfig:{has:{},paths:{},map:{},packages:[]}},request:{httpsDomains:["arcgis.com","arcgisonline.com","esrikr.com","premiumservices.blackbridge.com","esripremium.accuweather.com","gbm.digitalglobe.com","firstlook.digitalglobe.com","msi.digitalglobe.com"],interceptors:[],maxUrlLength:2e3,proxyRules:[],proxyUrl:null,timeout:6e4,trustedServers:[],useIdentity:!0},log:{interceptors:[],level:null}};if(e.esriConfig&&(r(s,e.esriConfig,!0),delete s.has),!s.assetsPath){const e="4.21.0";s.assetsPath=`https://js.arcgis.com/${e.slice(0,-2)}/@arcgis/core/assets`}s.baseUrl&&console.warn("[esri.config]","baseUrl has been replaced by assetsPath"),Object.defineProperty(s,"baseUrl",{set(){console.warn("[esri.config]","baseUrl has been replaced by assetsPath")}}),s.request.corsEnabledServers=[],s.request.corsEnabledServers.push=function(){return console.warn("[esri.config]","request.corsEnabledServers is not supported and will be removed in a future release. See http://esriurl.com/cors8664"),0};export{s as default};
package/interfaces.d.ts CHANGED
@@ -1942,7 +1942,7 @@ declare namespace __esri {
1942
1942
 
1943
1943
  export interface ConnectionInvokeOptions extends Object {
1944
1944
  /**
1945
- * An array of [Transferable](https://developer.mozilla.org/en-US/docs/Web/API/Transferable) objects.
1945
+ * An array of Transferable objects.
1946
1946
  *
1947
1947
  * [Read more...](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-workers-Connection.html#invoke)
1948
1948
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.21.0-next.20210919",
3
+ "version": "4.21.0",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS API for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- const c="20210919",e="7af981986c27c72861157e806678f7b0bc90e719";export{c as buildDate,e as commitHash};
5
+ const e="20210922",f="aef4166d070e919476e6cf2284f60caf022ae200";export{e as buildDate,f as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import i from"../../../Graphic.js";import{flatten as r}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import a from"../../../core/Error.js";import n from"../../../core/has.js";import{clone as l}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{andThen as h,unwrapOr as u,isSome as d,isNone as p}from"../../../core/maybe.js";import{debounce as c,eachAlwaysValues as f,isAbortError as y,after as g}from"../../../core/promiseUtils.js";import{init as m,whenFalseOnce as _}from"../../../core/watchUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../layers/effects/EffectList.js";import{calculateTolerance as x}from"../../../renderers/support/clickToleranceUtils.js";import w from"../../../rest/support/FeatureSet.js";import S from"../../../rest/support/Query.js";import{MAX_FILTERS as F}from"../engine/webgl/definitions.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{createSchema as I}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as O}from"./features/tileRenderers.js";import{computePxBuffer as E}from"./features/support/pixelBuffering.js";import{findSizeVV as T,createClusterCountSizeVariable as C,isClusterCompatibleRenderer as j,createClusterRenderer as q}from"./support/clusterUtils.js";import P from"./support/FeatureCommandQueue.js";import V from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as N}from"../tiling/TileManager.js";import{FeatureLayerView as H}from"../../layers/FeatureLayerView.js";import k from"../../layers/LayerView.js";import{RefreshableLayerView as J}from"../../layers/RefreshableLayerView.js";import z from"../../layers/support/FeatureFilter.js";import A from"../../layers/support/FeatureEffect.js";import{createQueryGeometry as $}from"../../support/drapedUtils.js";import B from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";const Q=2147483648,G=1,D=e=>(e&Q)>>>31===G;function K(e){return e&&"openPorts"in e}const W=o.getLogger("esri.views.2d.layers.FeatureLayerView2D");let X=class extends(H(J(U(k)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new P({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh();case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._effect=null,this._highlightIds=new Map,this._lastPixelBuffer=0,this._updateHighlight=c((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.filter=null,this.effectLists={included:new R,excluded:new R}}destroy(){var e,t;h(this._updateClusterSizeTask,(e=>e.remove())),null==(e=this._proxy)||e.destroy(),null==(t=this.tileRenderer)||t.destroy(),this._commandsQueue.destroy()}initialize(){this.addResolvingPromise(Promise.all([this._initProxy(),this._initServiceOptions()])),this.handles.add([this.on("valueRangesChanged",(e=>{this._set("_aggregateValueRanges",e.valueRanges)})),m(this,"effect",(e=>{this.effectLists.included.effect=null==e?void 0:e.includedEffect})),m(this,"effect",(e=>{this.effectLists.excluded.effect=null==e?void 0:e.excludedEffect}))])}async _initProxy(){if("isTable"in this.layer&&this.layer.isTable)throw new a("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});this._proxy&&this._proxy.destroy();const e=this._createClientOptions();return this._set("_proxy",new V({client:e})),this._proxy.when()}async _initServiceOptions(){this._set("_serviceOptions",await this._createServiceOptions())}get orderByFields(){return"stream"!==this._serviceOptions.type&&this._serviceOptions.orderByFields}get labelsVisible(){const e="subtype-group"===this.layer.type?this.layer.sublayers.items:[this.layer];return!this.suspended&&e.some((e=>e.labelingInfo&&e.labelsVisible))}get effect(){return u(this._effect,null)}set effect(e){const t=this._effect;d(t)&&d(t.filter)&&t.filter.enabled&&d(e)&&d(e.filter)&&e.filter.enable(),this._effect=e,this.notifyChange("effect")}get effects(){return this.effect&&[this.effect]||[]}get queryMode(){return this._serviceOptions.type}get renderingConfigHash(){if(!this.layer)return null;const e=this.availableFields,t=this.layer,i=this.view.floors,{definitionExpression:r}=t,s="subtype-group"!==this.layer.type&&this.layer.labelsVisible&&this.layer.labelingInfo,a="renderer"in t&&t.renderer,n="feature"===t.type?t.gdbVersion:void 0,l="feature"===t.type&&t.historicMoment?t.historicMoment.getTime():void 0,{timeExtent:o}=this,h="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,u=JSON.stringify(this.clips),p=t.featureReduction&&t.featureReduction.toJSON(),c="orderBy"in this.layer&&JSON.stringify(this.layer.orderBy),f="sublayers"in this.layer&&this.layer.sublayers.items.reduce(((e,t)=>e+`${t.visible?1:0}.${JSON.stringify(t.renderer)}.${t.labelsVisible}\n.${JSON.stringify(t.labelingInfo)}`),"");return JSON.stringify({orderBy:c,sublayerHash:f,filterHash:d(this.filter)&&this.filter.toJSON(),effectHash:d(this.effect)&&this.effect.toJSON(),streamFilter:h,gdbVersion:n,definitionExpression:r,historicMoment:l,availableFields:e,renderer:a,labelingInfo:s,timeExtent:o,floors:i,clipsHash:u,featureReduction:p})}get hasEffects(){return this.effectLists.included.hasEffects||this.effectLists.excluded.hasEffects}highlight(e){let t;return e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:s.isCollection(e)?t=e.map((e=>e&&e.getAttribute(this.layer.objectIdField))).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e&&e.getAttribute(this.layer.objectIdField)))),t&&t.length?(t=t.filter((e=>null!=e)),this._addHighlight(t),{remove:()=>this._removeHighlight(t)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}hitTest(e,t){return this._hitTest(e,t)}async queryAggregates(){return(await this._proxy.getAggregates()).map((e=>t.fromJSON(e)))}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t};var s;t.valueExpression&&(r.viewInfoParams={viewingMode:"map",scale:this.view.scale,spatialReference:null==(s=this.view.spatialReference)?void 0:s.toJSON()});return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=w.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}queryFeaturesJSON(e,t){return this._proxy.queryFeatures(this._cleanUpQuery(e),t)}queryObjectIds(e,t){return this._proxy.queryObjectIds(this._cleanUpQuery(e),t)}queryFeatureCount(e,t){return this._proxy.queryFeatureCount(this._cleanUpQuery(e),t)}queryExtent(e,t){return this._proxy.queryExtent(this._cleanUpQuery(e),t).then((e=>({count:e.count,extent:M.fromJSON(e.extent)})))}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._tileStrategy||!this.tileRenderer)return;const{hasMissingTiles:t,added:i,removed:r}=this._tileStrategy.update(e);(i.length||r.length)&&this._proxy.updateTiles({added:i,removed:r}),t&&this.requestUpdate(),this.notifyChange("updating")}attach(){this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._tileStrategy=new N({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(m(this,"renderingConfigHash",(()=>this._update())),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer&&(this.tileRenderer.uninstall(this.container),this.tileRenderer=null),this._tileStrategy&&(this._tileStrategy.destroy(),this._tileStrategy=null),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}async fetchPopupFeatures(e,i){if(d(i)&&i.clientGraphics.length){const e=i.clientGraphics[0];if(e instanceof t)return[e];i.clientGraphics=i.clientGraphics.filter((e=>{const{layer:t}=e,i="popupEnabled"in t&&t.popupEnabled,r="popupTemplate"in t&&t.popupTemplate,s=this.view.popup.defaultPopupTemplateEnabled;return i&&(r||s)}))}const s=this.validateFetchPopupFeatures(i);if(s)throw s;if(d(i)&&0===i.clientGraphics.length)return[];const a=this.fetchClientPopupFeatures(i);if(!e)return a;const n=this._fetchServicePopupFeatures(e,i);return f([a,n]).then(r)}async _fetchServicePopupFeatures(e,t){if("stream"===this.layer.type||"ogc-feature"===this.layer.type)return[];const i=await this.createPopupQuery(t),{layer:r}=this,s="renderer"in r&&r.renderer,a=d(t)?t.event:null,n=x({renderer:s,event:a});i.geometry=this.createFetchPopupFeaturesQueryGeometry(e,n);const l=new Set,{objectIdField:o}=r,h=d(t)?t.clientGraphics:null;if(h)for(const u of h)l.add(u.attributes[o]);return r.queryFeatures(i).then((e=>e.features.filter((e=>!l.has(e.attributes[o])))))}createFetchPopupFeaturesQueryGeometry(e,t){return $(e,t,this.view)}isUpdating(){var e;const t="renderer"in this.layer&&null!=this.layer.renderer,i=this._commandsQueue.updating,r=null!=this._updatingRequiredFieldsPromise,s=!this._proxy||!this._proxy.isReady,a=this._pipelineIsUpdating,l=null===this.tileRenderer||(null==(e=this.tileRenderer)?void 0:e.updating),o=t&&(i||r||s||a||l);return n("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${o}\n -> hasRenderer ${t}\n -> hasPendingCommand ${i}\n -> updatingRequiredFields ${r}\n -> updatingProxy ${s}\n -> updatingPipeline ${a}\n -> updatingTileRenderer ${l}\n`),o}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){if("path"in e&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&n("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=n("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=n("featurelayer-snapshot-point-max-threshold"),i=n("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=this.layer.fullExtent,a=null==s?void 0:s.clone().intersection(r),l=d(a)?a.width*a.height:0,o=(null==s?void 0:s.width)*(null==s?void 0:s.height),h=0===o?0:l/o;if(e<=t&&h>=i)return{mode:"snapshot",featureCount:e}}catch(t){W.warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:t})}return{mode:"on-demand"}}async _createServiceOptions(){var e;const t=this.layer;if("stream"===t.type)return null;const{capabilities:i,objectIdField:r}=t,s=t.fields.map((e=>e.toJSON())),a=t.fullExtent&&t.fullExtent.toJSON(),n=L(t.geometryType),o=t.timeInfo&&t.timeInfo.toJSON()||null,h=t.spatialReference?t.spatialReference.toJSON():null,u={..."customParameters"in t?t.customParameters:void 0,token:"apiKey"in t?t.apiKey:void 0},p="feature"===t.type?t.globalIdField:null;let c;"ogc-feature"===t.type?c=t.source.getFeatureDefinition():K(t.source)?c=await t.source.openPorts():t.parsedUrl&&(c=l(t.parsedUrl),"dynamicDataSource"in t&&t.dynamicDataSource&&(c.query={layer:JSON.stringify({source:t.dynamicDataSource})}));const f="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,y=null!=(e="subtypeField"in this.layer&&this.layer.subtypeField)?e:null,{mode:g,featureCount:m}=await this._detectQueryMode(c);let _=this.layer.objectIdField;if("feature"===this.layer.type&&d(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(_=e)}return{type:g,timeReferenceUnknownClient:f,subtypeField:y,featureCount:m,globalIdField:p,maxRecordCount:i.query.maxRecordCount,tileMaxRecordCount:i.query.tileMaxRecordCount,capabilities:i,fields:s,fullExtent:a,geometryType:n,objectIdField:r,source:c,timeInfo:o,spatialReference:h,customParameters:u,orderByFields:_}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=S.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this._validateEdit(e))return this._commandsQueue.push({type:"edit",edits:e})}async doRefresh(){return this._commandsQueue.push({type:"refresh"})}_validateEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,i=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),r=t&&this.availableFields.includes(t);return i&&!r?(W.error(new a("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null):e}async _doUpdate(){try{if(this.destroyed||!this._hasRequiredSupport(this.layer)||!this._tileStrategy)return;const{effect:t,filter:i}=this;await this._updateRequiredFields();const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=L(this.layer.geometryType),n=await E(r,a,this.layer.featureReduction),l=this._createConfiguration(s,i,t);this._lastPixelBuffer=0===n?0:Math.max(n,this._lastPixelBuffer),l.schema.source.pixelBuffer=this._lastPixelBuffer;const o=this._createTileRendererHash(r);if(o!==this._tileRendererHash){await this._initTileRenderer(r);const e=this._serviceOptions;this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r);const t={added:this._tileStrategy.tileKeys(),removed:[]},i=this.layer;"stream"!==i.type&&K(i.source)&&(e.source=await i.source.openPorts()),"stream"===i.type&&await this._initServiceOptions(),await this._proxy.startup(this.view.featuresTilingScheme,l,e,t),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{const t=await this._proxy.update(l);(t.mesh||t.targets.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){y(e)||W.error(e)}(t.mesh||t.targets.aggregate)&&this._unlockGPUUploads(),this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=o,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){y(t),0}}async _doRefresh(){this._lockGPUUploads();try{await this._proxy.refresh()}catch(e){y(e),0}this._unlockGPUUploads()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return this.watch("_aggregateValueRanges",(async i=>{this._updateClusterEffectiveRendererSizeVariable(e,t,i),this._needsClusterSizeUpdate=!0,this._uploadsLocked||this._updateClusterSizeVariable()}))}async _updateClusterEffectiveRendererSizeVariable(e,t,i){if(e.dynamicClusterSize&&"visualVariables"in e&&e.visualVariables){const r=T(e.visualVariables);if(d(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=C(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e="renderer"in this.layer&&this.layer.renderer,t=this.layer.featureReduction;if(d(this._updateClusterSizeTask)&&(this._updateClusterSizeTask.remove(),this._updateClusterSizeTask=null),t&&"cluster"===t.type&&j(e)){const i=t,r=[],s=q(r,e,i,this._aggregateValueRanges);return h(this._updateClusterSizeTask,(e=>e.remove())),this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,i),{renderer:s,aggregateFields:r,featureReduction:t}}return{renderer:e,aggregateFields:[],featureReduction:null}}_acquireTile(e){const t=this.tileRenderer.acquireTile(e);return t.once("attach",(()=>{this.requestUpdate()})),t}_releaseTile(e){this.tileRenderer.releaseTile(e)}async _initTileRenderer(e){const t=await O(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer.destroy(),this.tileRenderer=null),this.destroyed?null:(this._proxy.tileRenderer=t,this._set("tileRenderer",t),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(e),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${"heatmap"===e.type?"heatmap":"symbol"}.${"dot-density"===e.type}`}_createFeatureDataHash(e,t,i){const r=e.getAttributeHash(),s=JSON.stringify(t),a=d(i)&&JSON.stringify(i.filter),n=JSON.stringify(this.timeExtent);let l="";return this._visibilityOverrides.forEach((e=>l+=e)),`${r}.${s}.${a}.${n}.${l}`}get hasFilter(){const e=!!("floorInfo"in this.layer&&this.layer.floorInfo&&this.view.floors&&this.view.floors.length);return!!this.filter||e||!!this._visibilityOverrides.size||!!this.timeExtent}_injectOverrides(e){const t=d(e)?e.timeExtent:null,i=d(this.timeExtent)&&d(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=d(e)&&e.where;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return e;const a=d(e)&&e.clone()||new z;return a.hiddenIds=this._visibilityOverrides,a.timeExtent=i,r&&(a.where=r),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){var r;let e=this.view.floors;if(!e||!e.length)return i;null!=(r=t.floorInfo.viewAllLevelIds)&&r.length&&(e=t.floorInfo.viewAllLevelIds);const s=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));s.push("''");const a=t.floorInfo.floorField;let n="("+a+" IN ({ids}) OR "+a+" IS NULL)";if(n=n.replace("{ids}",s.join(", ")),d(i)&&i.includes(a)){let e=new RegExp("AND \\("+a+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+a+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+n:n}return""!==i?i:null}_createConfiguration(e,t,i){const r="feature"===this.layer.type&&this.layer.historicMoment?this.layer.historicMoment.getTime():void 0,s="feature"===this.layer.type?this.layer.gdbVersion:void 0,a=new Array(F),n=this._injectOverrides(t);a[0]=d(n)?n.toJSON():null,a[1]=d(i)&&i.filter?i.filter.toJSON():null;const l=I(e);if(p(l))return null;const o=B();return{definitionExpression:this.layer.definitionExpression,availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:l,supportsTextureFloat:o.supportsTextureFloat,maxTextureSize:o.maxTextureSize}}_hasRequiredSupport(e){var t;return!("renderer"in e&&"dot-density"===(null==(t=e.renderer)?void 0:t.type)&&!B().supportsTextureFloat)||(W.error(new a("webgl-missing-extension","Missing WebGL extension OES_Texture_Float which is required for DotDensity")),!1)}_onceTilesUpdated(){return this.requestUpdate(),_(this,"_pipelineIsUpdating",!1)}_lockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!0,this.tileRenderer.lockGPUUploads())}_unlockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!1,this.tileRenderer.unlockGPUUploads())}_forceAttributeTextureUpload(){this.tileRenderer&&this.tileRenderer.forceAttributeTextureUpload()}_createSchemaConfig(){const e="feature"===this.layer.type?this.layer.historicMoment:null,t="feature"===this.layer.type?this.layer.gdbVersion:null;return{renderer:"renderer"in this.layer&&this.layer.renderer,spatialReference:this.layer.spatialReference,timeExtent:this.layer.timeExtent,definitionExpression:this.layer.definitionExpression,featureReduction:this.layer.featureReduction,fields:this.layer.fields,geometryType:this.layer.geometryType,historicMoment:e,labelsVisible:"labelsVisible"in this.layer&&this.layer.labelsVisible,labelingInfo:"labelingInfo"in this.layer&&this.layer.labelingInfo,availableFields:this.availableFields,effect:this.effect,filter:this.filter,gdbVersion:t,pixelBuffer:0,orderBy:"orderBy"in this.layer&&this.layer.orderBy?this.layer.orderBy:null}}_addHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t);this._highlightIds.set(t,e+1)}else this._highlightIds.set(t,1);this._updateHighlight().catch((e=>{y(e)||W.error(e)}))}_removeHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t)-1;0===e?this._highlightIds.delete(t):this._highlightIds.set(t,e)}this._updateHighlight().catch((e=>{y(e)||W.error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createHittestResult(e){return this._setLayersForFeature(e),d(e.geometry)&&(e.geometry.spatialReference=this.view.spatialReference),e}async _hitTest(e,r){if(this.suspended||!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(e,r);if(0===s.length)return await g(1),null;const a=s[0];if(!D(a)){const e=await this._proxy.getFeature(a);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}const n=await this._proxy.getAggregate(a);if(p(n))return null;if(d(n.referenceId)){const e=await this._proxy.getFeature(n.referenceId);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}return this._createHittestResult(t.fromJSON(n))}};e([v()],X.prototype,"_serviceOptions",void 0),e([v()],X.prototype,"_proxy",void 0),e([v()],X.prototype,"_pipelineIsUpdating",void 0),e([v()],X.prototype,"_effectiveRenderer",void 0),e([v()],X.prototype,"_aggregateValueRanges",void 0),e([v()],X.prototype,"_commandsQueue",void 0),e([v()],X.prototype,"labelsVisible",null),e([v({type:z})],X.prototype,"filter",void 0),e([v({type:A})],X.prototype,"effect",null),e([v({readOnly:!0})],X.prototype,"effects",null),e([v({readOnly:!0})],X.prototype,"queryMode",null),e([v()],X.prototype,"renderingConfigHash",null),e([v()],X.prototype,"tileRenderer",void 0),e([v()],X.prototype,"updating",void 0),X=e([b("esri.views.2d.layers.FeatureLayerView2D")],X);var Y=X;export{Y as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../AggregateGraphic.js";import"../../../geometry.js";import i from"../../../Graphic.js";import{flatten as r}from"../../../core/arrayUtils.js";import s from"../../../core/Collection.js";import a from"../../../core/Error.js";import n from"../../../core/has.js";import{clone as l}from"../../../core/lang.js";import o from"../../../core/Logger.js";import{andThen as h,unwrapOr as u,isSome as d,isNone as p}from"../../../core/maybe.js";import{debounce as c,eachAlwaysValues as y,isAbortError as f,after as g}from"../../../core/promiseUtils.js";import{init as m,whenFalseOnce as _}from"../../../core/watchUtils.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../../core/accessorSupport/decorators/subclass.js";import R from"../../../layers/effects/EffectList.js";import{calculateTolerance as x}from"../../../renderers/support/clickToleranceUtils.js";import w from"../../../rest/support/FeatureSet.js";import S from"../../../rest/support/Query.js";import{MAX_FILTERS as F}from"../engine/webgl/definitions.js";import{LayerView2DMixin as U}from"./LayerView2D.js";import{createSchema as I}from"./features/schemaUtils.js";import{createOrReuseTileRenderer as O}from"./features/tileRenderers.js";import{computePxBuffer as E}from"./features/support/pixelBuffering.js";import{findSizeVV as T,createClusterCountSizeVariable as C,isClusterCompatibleRenderer as j,createClusterRenderer as P}from"./support/clusterUtils.js";import q from"./support/FeatureCommandQueue.js";import V from"./support/FeatureLayerProxy.js";import{toJSONGeometryType as L}from"./support/util.js";import{TileManager as N}from"../tiling/TileManager.js";import{FeatureLayerView as H}from"../../layers/FeatureLayerView.js";import J from"../../layers/LayerView.js";import{RefreshableLayerView as k}from"../../layers/RefreshableLayerView.js";import z from"../../layers/support/FeatureFilter.js";import A from"../../layers/support/FeatureEffect.js";import{createQueryGeometry as $}from"../../support/drapedUtils.js";import B from"../../webgl/capabilities.js";import M from"../../../geometry/Extent.js";const Q=2147483648,G=1,D=e=>(e&Q)>>>31===G;function K(e){return e&&"openPorts"in e}const W=o.getLogger("esri.views.2d.layers.FeatureLayerView2D");let X=class extends(H(k(U(J)))){constructor(){super(...arguments),this._pipelineIsUpdating=!0,this._commandsQueue=new q({process:e=>{switch(e.type){case"processed-edit":return this._doEdit(e);case"refresh":return this._doRefresh();case"update":return this._doUpdate()}}}),this._visibilityOverrides=new Set,this._effect=null,this._highlightIds=new Map,this._lastPixelBuffer=0,this._updateHighlight=c((async()=>this._proxy.setHighlight(Array.from(this._highlightIds.keys())))),this._uploadsLocked=!1,this._needsClusterSizeUpdate=!1,this.filter=null,this.effectLists={included:new R,excluded:new R}}destroy(){var e,t;h(this._updateClusterSizeTask,(e=>e.remove())),null==(e=this._proxy)||e.destroy(),null==(t=this.tileRenderer)||t.destroy(),this._commandsQueue.destroy()}initialize(){this.addResolvingPromise(Promise.all([this._initProxy(),this._initServiceOptions()])),this.handles.add([this.on("valueRangesChanged",(e=>{this._set("_aggregateValueRanges",e.valueRanges)})),m(this,"effect",(e=>{this.effectLists.included.effect=null==e?void 0:e.includedEffect})),m(this,"effect",(e=>{this.effectLists.excluded.effect=null==e?void 0:e.excludedEffect}))])}async _initProxy(){if("isTable"in this.layer&&this.layer.isTable)throw new a("featurelayerview:table-not-supported","table feature layer can't be displayed",{layer:this.layer});this._proxy&&this._proxy.destroy();const e=this._createClientOptions();return this._set("_proxy",new V({client:e})),this._proxy.when()}async _initServiceOptions(){this._set("_serviceOptions",await this._createServiceOptions())}get orderByFields(){return"stream"!==this._serviceOptions.type&&this._serviceOptions.orderByFields}get labelsVisible(){const e="subtype-group"===this.layer.type?this.layer.sublayers.items:[this.layer];return!this.suspended&&e.some((e=>e.labelingInfo&&e.labelsVisible))}get effect(){return u(this._effect,null)}set effect(e){const t=this._effect;d(t)&&d(t.filter)&&t.filter.enabled&&d(e)&&d(e.filter)&&e.filter.enable(),this._effect=e,this.notifyChange("effect")}get effects(){return this.effect&&[this.effect]||[]}get queryMode(){return this._serviceOptions.type}get renderingConfigHash(){if(!this.layer)return null;const e=this.availableFields,t=this.layer,i=this.view.floors,{definitionExpression:r}=t,s="subtype-group"!==this.layer.type&&this.layer.labelsVisible&&this.layer.labelingInfo,a="renderer"in t&&t.renderer,n="feature"===t.type?t.gdbVersion:void 0,l="feature"===t.type&&t.historicMoment?t.historicMoment.getTime():void 0,{timeExtent:o}=this,h="customParameters"in t?JSON.stringify(t.customParameters):void 0,u="apiKey"in t?t.apiKey:void 0,p="stream"===t.type?`${JSON.stringify(t.geometryDefinition)}${t.definitionExpression}`:null,c=JSON.stringify(this.clips),y=t.featureReduction&&t.featureReduction.toJSON(),f="orderBy"in this.layer&&JSON.stringify(this.layer.orderBy),g="sublayers"in this.layer&&this.layer.sublayers.items.reduce(((e,t)=>e+`${t.visible?1:0}.${JSON.stringify(t.renderer)}.${t.labelsVisible}\n.${JSON.stringify(t.labelingInfo)}`),"");return JSON.stringify({orderBy:f,sublayerHash:g,filterHash:d(this.filter)&&this.filter.toJSON(),effectHash:d(this.effect)&&this.effect.toJSON(),streamFilter:p,gdbVersion:n,definitionExpression:r,historicMoment:l,availableFields:e,renderer:a,labelingInfo:s,timeExtent:o,floors:i,clipsHash:c,featureReduction:y,customParameters:h,apiKey:u})}get hasEffects(){return this.effectLists.included.hasEffects||this.effectLists.excluded.hasEffects}highlight(e){let t;return e instanceof i?t=[e.getObjectId()]:"number"==typeof e||"string"==typeof e?t=[e]:s.isCollection(e)?t=e.map((e=>e&&e.getAttribute(this.layer.objectIdField))).toArray():Array.isArray(e)&&e.length>0&&(t="number"==typeof e[0]||"string"==typeof e[0]?e:e.map((e=>e&&e.getAttribute(this.layer.objectIdField)))),t&&t.length?(t=t.filter((e=>null!=e)),this._addHighlight(t),{remove:()=>this._removeHighlight(t)}):{remove:()=>{}}}hasHighlight(){return!!this._highlightIds.size}hitTest(e,t){return this._hitTest(e,t)}async queryAggregates(){return(await this._proxy.getAggregates()).map((e=>t.fromJSON(e)))}queryStatistics(){return this._proxy.queryStatistics()}async querySummaryStatistics(e,t,i){const r={...t};var s;t.valueExpression&&(r.viewInfoParams={viewingMode:"map",scale:this.view.scale,spatialReference:null==(s=this.view.spatialReference)?void 0:s.toJSON()});return this._proxy.querySummaryStatistics(this._cleanUpQuery(e),r,i)}queryFeatures(e,t){return this.queryFeaturesJSON(e,t).then((e=>{const t=w.fromJSON(e);return t.features.forEach((e=>this._setLayersForFeature(e))),t}))}queryFeaturesJSON(e,t){return this._proxy.queryFeatures(this._cleanUpQuery(e),t)}queryObjectIds(e,t){return this._proxy.queryObjectIds(this._cleanUpQuery(e),t)}queryFeatureCount(e,t){return this._proxy.queryFeatureCount(this._cleanUpQuery(e),t)}queryExtent(e,t){return this._proxy.queryExtent(this._cleanUpQuery(e),t).then((e=>({count:e.count,extent:M.fromJSON(e.extent)})))}setVisibility(e,t){t?this._visibilityOverrides.delete(e):this._visibilityOverrides.add(e),this._update()}update(e){if(!this._tileStrategy||!this.tileRenderer)return;const{hasMissingTiles:t,added:i,removed:r}=this._tileStrategy.update(e);(i.length||r.length)&&this._proxy.updateTiles({added:i,removed:r}),t&&this.requestUpdate(),this.notifyChange("updating")}attach(){this.view.timeline.record(`${this.layer.title} (FeatureLayer) Attach`),this._tileStrategy=new N({acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme,buffer:0}),this.handles.add(m(this,"renderingConfigHash",(()=>this._update())),"attach"),"stream"!==this.layer.type&&this.handles.add(this.layer.on("edits",(e=>this._edit(e))),"attach")}detach(){this.container.removeAllChildren(),this.handles.remove("attach"),this.tileRenderer&&(this.tileRenderer.uninstall(this.container),this.tileRenderer=null),this._tileStrategy&&(this._tileStrategy.destroy(),this._tileStrategy=null),this._tileRendererHash=null}moveStart(){this.requestUpdate()}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}async fetchPopupFeatures(e,i){if(d(i)&&i.clientGraphics.length){const e=i.clientGraphics[0];if(e instanceof t)return[e];i.clientGraphics=i.clientGraphics.filter((e=>{const{layer:t}=e,i="popupEnabled"in t&&t.popupEnabled,r="popupTemplate"in t&&t.popupTemplate,s=this.view.popup.defaultPopupTemplateEnabled;return i&&(r||s)}))}const s=this.validateFetchPopupFeatures(i);if(s)throw s;if(d(i)&&0===i.clientGraphics.length)return[];const a=this.fetchClientPopupFeatures(i);if(!e)return a;const n=this._fetchServicePopupFeatures(e,i);return y([a,n]).then(r)}async _fetchServicePopupFeatures(e,t){if("stream"===this.layer.type||"ogc-feature"===this.layer.type)return[];const i=await this.createPopupQuery(t),{layer:r}=this,s="renderer"in r&&r.renderer,a=d(t)?t.event:null,n=x({renderer:s,event:a});i.geometry=this.createFetchPopupFeaturesQueryGeometry(e,n);const l=new Set,{objectIdField:o}=r,h=d(t)?t.clientGraphics:null;if(h)for(const u of h)l.add(u.attributes[o]);return r.queryFeatures(i).then((e=>e.features.filter((e=>!l.has(e.attributes[o])))))}createFetchPopupFeaturesQueryGeometry(e,t){return $(e,t,this.view)}isUpdating(){var e;const t="renderer"in this.layer&&null!=this.layer.renderer,i=this._commandsQueue.updating,r=null!=this._updatingRequiredFieldsPromise,s=!this._proxy||!this._proxy.isReady,a=this._pipelineIsUpdating,l=null===this.tileRenderer||(null==(e=this.tileRenderer)?void 0:e.updating),o=t&&(i||r||s||a||l);return n("esri-2d-log-updating")&&console.log(`Updating FLV2D: ${o}\n -> hasRenderer ${t}\n -> hasPendingCommand ${i}\n -> updatingRequiredFields ${r}\n -> updatingProxy ${s}\n -> updatingPipeline ${a}\n -> updatingTileRenderer ${l}\n`),o}_createClientOptions(){return{setUpdating:e=>{this._set("_pipelineIsUpdating",e)},emitEvent:e=>{this.emit(e.name,e.event)}}}async _detectQueryMode(e){if("path"in e&&("feature"===this.layer.type||"subtype-group"===this.layer.type)&&"point"===this.layer.geometryType&&this.layer.capabilities.query.supportsPagination&&!this.layer.capabilities.operations.supportsEditing&&n("featurelayer-snapshot-enabled"))try{const e=await this.layer.queryFeatureCount();if(e<=n("featurelayer-snapshot-point-min-threshold"))return{mode:"snapshot",featureCount:e};const t=n("featurelayer-snapshot-point-max-threshold"),i=n("featurelayer-snapshot-point-coverage"),r=this.view.extent,s=this.layer.fullExtent,a=null==s?void 0:s.clone().intersection(r),l=d(a)?a.width*a.height:0,o=(null==s?void 0:s.width)*(null==s?void 0:s.height),h=0===o?0:l/o;if(e<=t&&h>=i)return{mode:"snapshot",featureCount:e}}catch(t){W.warn("mapview-feature-layer","Encountered an error when querying for featureCount",{error:t})}return{mode:"on-demand"}}async _createServiceOptions(){var e;const t=this.layer;if("stream"===t.type)return null;const{capabilities:i,objectIdField:r}=t,s=t.fields.map((e=>e.toJSON())),a=t.fullExtent&&t.fullExtent.toJSON(),n=L(t.geometryType),o=t.timeInfo&&t.timeInfo.toJSON()||null,h=t.spatialReference?t.spatialReference.toJSON():null,u="feature"===t.type?t.globalIdField:null;let p;"ogc-feature"===t.type?p=t.source.getFeatureDefinition():K(t.source)?p=await t.source.openPorts():t.parsedUrl&&(p=l(t.parsedUrl),"dynamicDataSource"in t&&t.dynamicDataSource&&(p.query={layer:JSON.stringify({source:t.dynamicDataSource})}));const c="datesInUnknownTimezone"in this.layer&&this.layer.datesInUnknownTimezone,y=null!=(e="subtypeField"in this.layer&&this.layer.subtypeField)?e:null,{mode:f,featureCount:g}=await this._detectQueryMode(p);let m=this.layer.objectIdField;if("feature"===this.layer.type&&d(this.layer.orderBy)&&this.layer.orderBy.length){const e=!this.layer.orderBy[0].valueExpression&&this.layer.orderBy[0].field;e&&(m=e)}return{type:f,timeReferenceUnknownClient:c,subtypeField:y,featureCount:g,globalIdField:u,maxRecordCount:i.query.maxRecordCount,tileMaxRecordCount:i.query.tileMaxRecordCount,capabilities:i,fields:s,fullExtent:a,geometryType:n,objectIdField:r,source:p,timeInfo:o,spatialReference:h,orderByFields:m}}async _createMemoryServiceOptions(e){const t=await e.openPorts();return{...this._createServiceOptions(),type:"memory",source:t}}_cleanUpQuery(e){const t=S.from(e)||this.createQuery();return t.outSpatialReference||(t.outSpatialReference=this.view.spatialReference),t}async _update(){return this._commandsQueue.push({type:"update"})}async _edit(e){if(this._validateEdit(e))return this._commandsQueue.push({type:"edit",edits:e})}async doRefresh(){return this._commandsQueue.push({type:"refresh"})}_validateEdit(e){const t="globalIdField"in this.layer&&this.layer.globalIdField,i=e.deletedFeatures.some((e=>-1===e.objectId||!e.objectId)),r=t&&this.availableFields.includes(t);return i&&!r?(W.error(new a("mapview-apply-edits",`Editing the specified service requires the layer's globalIdField, ${t} to be included the layer's outFields for updates to be reflected on the map`)),null):e}async _doUpdate(){try{if(this.destroyed||!this._hasRequiredSupport(this.layer)||!this._tileStrategy)return;const{effect:t,filter:i}=this;await this._updateRequiredFields();const{renderer:r}=this._getEffectiveRenderer();this._set("_effectiveRenderer",r);const s=this._createSchemaConfig(),a=L(this.layer.geometryType),n=await E(r,a,this.layer.featureReduction),l=this._createConfiguration(s,i,t);this._lastPixelBuffer=0===n?0:Math.max(n,this._lastPixelBuffer),l.schema.source.pixelBuffer=this._lastPixelBuffer;const o=this._createTileRendererHash(r);if(o!==this._tileRendererHash){await this._initTileRenderer(r);const e=this._serviceOptions;this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r);const t={added:this._tileStrategy.tileKeys(),removed:[]},i=this.layer;"stream"!==i.type&&K(i.source)&&(e.source=await i.source.openPorts()),"stream"===i.type&&await this._initServiceOptions(),await this._proxy.startup(this.view.featuresTilingScheme,l,e,t),this.hasHighlight()&&await this._proxy.setHighlight(Array.from(this._highlightIds.keys())),await this._onceTilesUpdated(),this.tileRenderer.onConfigUpdate(r)}else{const t=await this._proxy.update(l);(t.mesh||t.targets.aggregate)&&this._lockGPUUploads();try{await this._proxy.applyUpdate(t)}catch(e){f(e)||W.error(e)}(t.mesh||t.targets.aggregate)&&this._unlockGPUUploads(),this.effects.forEach((e=>d(e)&&d(e.filter)&&e.filter.enable())),this.tileRenderer.onConfigUpdate(r),this._updateClusterSizeVariable(),this._forceAttributeTextureUpload()}this._tileRendererHash=o,this.tileRenderer.invalidateLabels(),this.requestUpdate()}catch(e){}}async _doEdit(e){try{await this._proxy.onEdits(e)}catch(t){f(t),0}}async _doRefresh(){this._lockGPUUploads();try{await this._proxy.refresh()}catch(e){f(e),0}this._unlockGPUUploads()}_updateClusterSizeVariable(){this._needsClusterSizeUpdate&&(this.tileRenderer.onConfigUpdate(this._effectiveRenderer),this._needsClusterSizeUpdate=!1)}_createUpdateClusterSizeTask(e,t){return this.watch("_aggregateValueRanges",(async i=>{this._updateClusterEffectiveRendererSizeVariable(e,t,i),this._needsClusterSizeUpdate=!0,this._uploadsLocked||this._updateClusterSizeVariable()}))}async _updateClusterEffectiveRendererSizeVariable(e,t,i){if(e.dynamicClusterSize&&"visualVariables"in e&&e.visualVariables){const r=T(e.visualVariables);if(d(r)&&"cluster_count"===r.field){const s=e.visualVariables.indexOf(r);e.visualVariables[s]=C(t,i);const a=e.clone();a.dynamicClusterSize=!0,this._set("_effectiveRenderer",a)}}}_getEffectiveRenderer(){const e="renderer"in this.layer&&this.layer.renderer,t=this.layer.featureReduction;if(d(this._updateClusterSizeTask)&&(this._updateClusterSizeTask.remove(),this._updateClusterSizeTask=null),t&&"cluster"===t.type&&j(e)){const i=t,r=[],s=P(r,e,i,this._aggregateValueRanges);return h(this._updateClusterSizeTask,(e=>e.remove())),this._updateClusterSizeTask=this._createUpdateClusterSizeTask(s,i),{renderer:s,aggregateFields:r,featureReduction:t}}return{renderer:e,aggregateFields:[],featureReduction:null}}_acquireTile(e){const t=this.tileRenderer.acquireTile(e);return t.once("attach",(()=>{this.requestUpdate()})),t}_releaseTile(e){this.tileRenderer.releaseTile(e)}async _initTileRenderer(e){const t=await O(e,{layerView:this,tileInfoView:this.view.featuresTilingScheme,layer:this.layer});return this.tileRenderer&&(this._tileStrategy.clear(),this.tileRenderer.uninstall(this.container),this.tileRenderer.destroy(),this.tileRenderer=null),this.destroyed?null:(this._proxy.tileRenderer=t,this._set("tileRenderer",t),this.tileRenderer.install(this.container),this.tileRenderer.onConfigUpdate(e),this.requestUpdate(),this.tileRenderer)}_createTileRendererHash(e){return`${"heatmap"===e.type?"heatmap":"symbol"}.${"dot-density"===e.type}`}_createFeatureDataHash(e,t,i){const r=e.getAttributeHash(),s=JSON.stringify(t),a=d(i)&&JSON.stringify(i.filter),n=JSON.stringify(this.timeExtent);let l="";return this._visibilityOverrides.forEach((e=>l+=e)),`${r}.${s}.${a}.${n}.${l}`}get hasFilter(){const e=!!("floorInfo"in this.layer&&this.layer.floorInfo&&this.view.floors&&this.view.floors.length);return!!this.filter||e||!!this._visibilityOverrides.size||!!this.timeExtent}_injectOverrides(e){const t=d(e)?e.timeExtent:null,i=d(this.timeExtent)&&d(t)?this.timeExtent.intersection(t):this.timeExtent||t;let r=null;const s="floorInfo"in this.layer&&this.layer.floorInfo;if(s){const t=d(e)&&e.where;r=this._addFloorFilterClause(t)}if(!this._visibilityOverrides.size&&!i&&!s)return e;const a=d(e)&&e.clone()||new z;return a.hiddenIds=this._visibilityOverrides,a.timeExtent=i,r&&(a.where=r),a}_addFloorFilterClause(e){const t=this.layer;let i=e||"";if("floorInfo"in t&&t.floorInfo){var r;let e=this.view.floors;if(!e||!e.length)return i;null!=(r=t.floorInfo.viewAllLevelIds)&&r.length&&(e=t.floorInfo.viewAllLevelIds);const s=e.filter((e=>""!==e)).map((e=>"'"+e+"'"));s.push("''");const a=t.floorInfo.floorField;let n="("+a+" IN ({ids}) OR "+a+" IS NULL)";if(n=n.replace("{ids}",s.join(", ")),d(i)&&i.includes(a)){let e=new RegExp("AND \\("+a+".*NULL\\)","g");i=i.replace(e,""),e=new RegExp("\\("+a+".*NULL\\)","g"),i=i.replace(e,""),i=i.replace(/\s+/g," ").trim()}i=""!==i?"("+i+") AND "+n:n}return""!==i?i:null}_createConfiguration(e,t,i){const r="feature"===this.layer.type&&this.layer.historicMoment?this.layer.historicMoment.getTime():void 0,s="feature"===this.layer.type?this.layer.gdbVersion:void 0,a=new Array(F),n=this._injectOverrides(t);a[0]=d(n)?n.toJSON():null,a[1]=d(i)&&i.filter?i.filter.toJSON():null;const l=I(e);if(p(l))return null;const o=B();return{definitionExpression:this.layer.definitionExpression,availableFields:this.availableFields,gdbVersion:s,historicMoment:r,devicePixelRatio:window.devicePixelRatio||1,filters:a,schema:l,supportsTextureFloat:o.supportsTextureFloat,maxTextureSize:o.maxTextureSize}}_hasRequiredSupport(e){var t;return!("renderer"in e&&"dot-density"===(null==(t=e.renderer)?void 0:t.type)&&!B().supportsTextureFloat)||(W.error(new a("webgl-missing-extension","Missing WebGL extension OES_Texture_Float which is required for DotDensity")),!1)}_onceTilesUpdated(){return this.requestUpdate(),_(this,"_pipelineIsUpdating",!1)}_lockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!0,this.tileRenderer.lockGPUUploads())}_unlockGPUUploads(){this.tileRenderer&&(this._uploadsLocked=!1,this.tileRenderer.unlockGPUUploads())}_forceAttributeTextureUpload(){this.tileRenderer&&this.tileRenderer.forceAttributeTextureUpload()}_createSchemaConfig(){const e="feature"===this.layer.type?this.layer.historicMoment:null,t="feature"===this.layer.type?this.layer.gdbVersion:null;return{renderer:"renderer"in this.layer&&this.layer.renderer,spatialReference:this.layer.spatialReference,timeExtent:this.layer.timeExtent,definitionExpression:this.layer.definitionExpression,featureReduction:this.layer.featureReduction,fields:this.layer.fields,geometryType:this.layer.geometryType,historicMoment:e,labelsVisible:"labelsVisible"in this.layer&&this.layer.labelsVisible,labelingInfo:"labelingInfo"in this.layer&&this.layer.labelingInfo,availableFields:this.availableFields,effect:this.effect,filter:this.filter,gdbVersion:t,pixelBuffer:0,orderBy:"orderBy"in this.layer&&this.layer.orderBy?this.layer.orderBy:null,customParameters:{..."customParameters"in this.layer?this.layer.customParameters:void 0,token:"apiKey"in this.layer?this.layer.apiKey:void 0}}}_addHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t);this._highlightIds.set(t,e+1)}else this._highlightIds.set(t,1);this._updateHighlight().catch((e=>{f(e)||W.error(e)}))}_removeHighlight(e){for(const t of e)if(this._highlightIds.has(t)){const e=this._highlightIds.get(t)-1;0===e?this._highlightIds.delete(t):this._highlightIds.set(t,e)}this._updateHighlight().catch((e=>{f(e)||W.error(e)}))}_setLayersForFeature(e){const t=this.layer;e.layer=t,e.sourceLayer=t}_createHittestResult(e){return this._setLayersForFeature(e),d(e.geometry)&&(e.geometry.spatialReference=this.view.spatialReference),e}async _hitTest(e,r){if(this.suspended||!this.tileRenderer)return null;const s=await this.tileRenderer.hitTest(e,r);if(0===s.length)return await g(1),null;const a=s[0];if(!D(a)){const e=await this._proxy.getFeature(a);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}const n=await this._proxy.getAggregate(a);if(p(n))return null;if(d(n.referenceId)){const e=await this._proxy.getFeature(n.referenceId);return h(e,(e=>this._createHittestResult(i.fromJSON(e))))}return this._createHittestResult(t.fromJSON(n))}};e([v()],X.prototype,"_serviceOptions",void 0),e([v()],X.prototype,"_proxy",void 0),e([v()],X.prototype,"_pipelineIsUpdating",void 0),e([v()],X.prototype,"_effectiveRenderer",void 0),e([v()],X.prototype,"_aggregateValueRanges",void 0),e([v()],X.prototype,"_commandsQueue",void 0),e([v()],X.prototype,"labelsVisible",null),e([v({type:z})],X.prototype,"filter",void 0),e([v({type:A})],X.prototype,"effect",null),e([v({readOnly:!0})],X.prototype,"effects",null),e([v({readOnly:!0})],X.prototype,"queryMode",null),e([v()],X.prototype,"renderingConfigHash",null),e([v()],X.prototype,"tileRenderer",void 0),e([v()],X.prototype,"updating",void 0),X=e([b("esri.views.2d.layers.FeatureLayerView2D")],X);var Y=X;export{Y 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.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../core/has.js";import{isSome as t,unwrap as r}from"../../../../../../core/maybe.js";import{openWithPorts as s}from"../../../../../../core/workers/workers.js";import{toQuantizationTransform as i}from"../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as a,quantizeOptimizedFeatureSet as o}from"../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as n}from"../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as u,executeQuery as c}from"../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as l}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as m}from"../../support/FeatureSetReaderPBF.js";class p{constructor(e){this.service=e}destroy(){}}function y(e){return Array.isArray(e.source)}function f(e){return e&&e.capabilities&&e.collection&&e.layerDefinition}function d(t){const{capabilities:r}=t;return f(t.source)?new F(t):y(t)?new h(t):r.query.supportsFormatPBF&&e("featurelayer-pbf")?new q(t):new v(t)}class h extends p{constructor(e){super(e),this._portsOpen=s(e.source).then((e=>this.client=e))}destroy(){this.client.close(),this.client=null}async executeQuery(e,t){await this._portsOpen;const r=await this.client.invoke("queryFeatures",e.toJSON(),t);return l.fromFeatureSet(r,this.service.objectIdField)}}class q extends p{async executeQuery(e,t){const{data:r}=await u(this.service.source,e,{signal:null==t?void 0:t.signal,query:{...null==t?void 0:t.query,...this.service.customParameters}}),s=!e.quantizationParameters;return m.fromBuffer(r,this.service.geometryType,s)}}class v extends p{async executeQuery(e,s){const{source:n,capabilities:u,spatialReference:m,objectIdField:p}=this.service;if(t(e.quantizationParameters)&&!u.query.supportsQuantization){const t=e.clone(),u=i(r(t.quantizationParameters));t.quantizationParameters=null;const{data:y}=await c(n,t,m,{signal:null==s?void 0:s.signal,query:{...null==s?void 0:s.query,...this.service.customParameters}}),f=a(y,p);return o(u,f),l.fromOptimizedFeatureSet(f)}const{data:y}=await c(n,e,this.service.spatialReference,{...s,query:{...null==s?void 0:s.query,...this.service.customParameters}});return l.fromFeatureSet(y,this.service.objectIdField)}}class F extends p{async executeQuery(e,t){const{capabilities:s}=this.service;if(e.quantizationParameters&&!s.query.supportsQuantization){const s=e.clone(),a=i(r(s.quantizationParameters));s.quantizationParameters=null;const u=await n(this.service.source,e,t);return o(a,u),l.fromOptimizedFeatureSet(u)}const a=await n(this.service.source,e,t);return l.fromOptimizedFeatureSet(a)}}export{p as SourceAdapter,d as createSourceAdapter};
5
+ import e from"../../../../../../core/has.js";import{isSome as t,unwrap as r}from"../../../../../../core/maybe.js";import{openWithPorts as s}from"../../../../../../core/workers/workers.js";import{toQuantizationTransform as i}from"../../../../../../geometry/support/quantizationUtils.js";import{convertFromFeatureSet as a,quantizeOptimizedFeatureSet as o}from"../../../../../../layers/graphics/featureConversionUtils.js";import{queryOptimizedFeatureSet as n}from"../../../../../../layers/ogc/ogcFeatureUtils.js";import{executeQueryPBFBuffer as c,executeQuery as u}from"../../../../../../rest/query/operations/query.js";import{FeatureSetReaderJSON as p}from"../../support/FeatureSetReaderJSON.js";import{FeatureSetReaderPBF as m}from"../../support/FeatureSetReaderPBF.js";class l{constructor(e){this.service=e}destroy(){}}function f(e){return Array.isArray(e.source)}function y(e){return e&&e.capabilities&&e.collection&&e.layerDefinition}function d(t){const{capabilities:r}=t;return y(t.source)?new w(t):f(t)?new h(t):r.query.supportsFormatPBF&&e("featurelayer-pbf")?new F(t):new q(t)}class h extends l{constructor(e){super(e),this._portsOpen=s(e.source).then((e=>this.client=e))}destroy(){this.client.close(),this.client=null}async executeQuery(e,t){await this._portsOpen;const r=await this.client.invoke("queryFeatures",e.toJSON(),t);return p.fromFeatureSet(r,this.service.objectIdField)}}class F extends l{async executeQuery(e,t){const{data:r}=await c(this.service.source,e,t),s=!e.quantizationParameters;return m.fromBuffer(r,this.service.geometryType,s)}}class q extends l{async executeQuery(e,s){const{source:n,capabilities:c,spatialReference:m,objectIdField:l}=this.service;if(t(e.quantizationParameters)&&!c.query.supportsQuantization){const t=e.clone(),c=i(r(t.quantizationParameters));t.quantizationParameters=null;const{data:f}=await u(n,t,m,s),y=a(f,l);return o(c,y),p.fromOptimizedFeatureSet(y)}const{data:f}=await u(n,e,this.service.spatialReference,s);return p.fromFeatureSet(f,this.service.objectIdField)}}class w extends l{async executeQuery(e,t){const{capabilities:s}=this.service;if(e.quantizationParameters&&!s.query.supportsQuantization){const s=e.clone(),a=i(r(s.quantizationParameters));s.quantizationParameters=null;const c=await n(this.service.source,e,t);return o(a,c),p.fromOptimizedFeatureSet(c)}const a=await n(this.service.source,e,t);return p.fromOptimizedFeatureSet(a)}}export{l as SourceAdapter,d as createSourceAdapter};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/Renderer.js";import e from"../../../../renderers/SimpleRenderer.js";import"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import t from"../../../../core/Error.js";import r from"../../../../core/has.js";import{clone as i}from"../../../../core/lang.js";import n from"../../../../core/Logger.js";import{isSome as l,isNone as s,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{fromJSON as u}from"../../../../symbols/support/jsonUtils.js";import{WGLGeometryType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{createMaterialKey as c,hydrateMaterialKey as p}from"../../engine/webgl/materialKey/MaterialKey.js";import{getVVFlags as m}from"../../engine/webgl/util/vvFlagUtils.js";import{getPtMaxVVSize as y}from"./support/pixelBuffering.js";import{simplifyVisualVariables as g}from"./support/rendererUtils.js";import{createClusterRenderer as b}from"../support/clusterUtils.js";import{toJSONGeometryType as h}from"../support/util.js";const x=n.getLogger("esri.views.2d.layers.features.schemaUtils"),v="ValidationError",w={esriGeometryPoint:["above-right","above-center","above-left","center-center","center-left","center-right","below-center","below-left","below-right"],esriGeometryPolygon:["always-horizontal"],esriGeometryPolyline:["center-along"],esriGeometryMultipoint:null};function E(e){return p(e)}function I(e){return e}function S(e){if("line-marker"===e.type){var t;return{type:"line-marker",color:null==(t=e.color)?void 0:t.toJSON(),placement:e.placement,style:e.style}}return u(e.toJSON()).toJSON()}function F(e,t,r){if(!e)return null;let i=0,n=!1,s=0;switch(l(t)&&(s=y(t),"visualVariables"in t&&(i=m(t.visualVariables||[]),n="dot-density"===t.type)),e.type){case"simple-fill":case"picture-fill":return V(e,i,n,r);case"simple-marker":case"picture-marker":return j(e,i,s,r);case"simple-line":return z(e,i,r);case"text":return T(e,i,s,r);case"label":return K(e,i,r);case"cim":return{type:"cim",rendererKey:i,data:e.data,maxVVSize:s};case"web-style":return{...S(e),type:"web-style",hash:e.hash(),rendererKey:i,maxVVSize:s};default:throw new Error(`symbol not supported ${e.type}`)}}function V(e,t,r,i){const n=c(d.FILL,t,!1,r),l=i?E(n):n,s=e.clone(),a=s.outline;s.outline=null;const o=[],u={materialKey:l,hash:s.hash(),...S(s)};if(o.push(u),a){const e=c(d.LINE,t,!0,!1),r={materialKey:i?E(e):e,hash:a.hash(),...S(a)};o.push(r)}return{type:"composite-symbol",layers:o,hash:o.reduce(((e,t)=>t.hash+e),"")}}function z(e,t,r){const i=c(d.LINE,t,!1,!1),n=r?E(i):i,l=e.clone(),s=l.marker;l.marker=null;const a=[];if(a.push({materialKey:n,hash:l.hash(),...S(l)}),s){var o;const e=c(d.MARKER,t,!1,!1),i=r?E(e):e;s.color=null!=(o=s.color)?o:l.color,a.push({materialKey:i,hash:s.hash(),lineWidth:l.width,...S(s)})}return{type:"composite-symbol",layers:a,hash:a.reduce(((e,t)=>t.hash+e),"")}}function j(e,t,r,i){const n=c(d.MARKER,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function T(e,t,r,i){const n=c(d.TEXT,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function N(e,r){const i=e.labelPlacement,n=w[r];if(!e.symbol)return x.warn("No ILabelClass symbol specified."),!0;if(!n)return x.error(new t("mapview-labeling:unsupported-geometry-type",`Unable to create labels for Feature Layer, ${r} is not supported`)),!0;if(!n.some((e=>e===i))){const t=n[0];i&&x.warn(`Found invalid label placement type ${i} for ${r}. Defaulting to ${t}`),e.labelPlacement=t}return!1}function R(e,t){const r=i(e);return r.some((e=>N(e,t)))?[]:r}function K(e,t,r){const i=e.toJSON(),n=c(d.LABEL,t,!1,!1,i.labelPlacement);return{materialKey:r?E(n):n,hash:e.hash(),...i,labelPlacement:i.labelPlacement}}function M(e){return r("esri-2d-update-debug")&&console.debug("Created new schema",O(e,!0)),O(e)}function O(e,t=!1){try{var r,i;const n=C(e,t),l={};n.map((t=>k(l,e,t)));return{source:{definitionExpression:e.definitionExpression,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:null==(r=e.historicMoment)?void 0:r.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:null==(i=e.timeExtent)?void 0:i.toJSON()},attributes:{fields:{},indexCount:0},processors:n,targets:l}}catch(n){if(n.fieldName===v)return x.error(n),null;throw n}}function k(e,r,i){switch(i.target){case"feature":return void J(e,L(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;if("selection"===n.type)throw new t(v,"Mapview does not support `selection` reduction type",n);return J(e,L(r),i),void D(e,n,i)}}}function B(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function L(e){var t,r,i,n,l;return[null!=(t=null==(r=e.filter)?void 0:r.toJSON())?t:null,null!=(i=null==(n=e.effect)||null==(l=n.filter)?void 0:l.toJSON())?i:null]}function J(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),B(e.feature,r.attributes.fields),e}function D(e,t,r){return e.aggregate||(e.aggregate={name:"aggregate",input:"feature",filters:null,attributes:{},params:{clusterRadius:o(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(o(t.clusterMaxSize)/64),fields:r.aggregateFields}}),B(e.aggregate,r.attributes.fields),e}function P(e,t){return t.field?U(e,{...t,type:"field",field:t.field}):t.valueExpression?U(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function U(e,t){switch(t.type){case"expression":{const r=I(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=I(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function C(e,t=!1){const r=new Array;let i=0;return r.push(q(e,i++,t)),r}function $(e,t,r,i,n,l=!1){const s=U(t,{type:"label-expression",target:i,context:{mesh:!0},resultType:"string",label:{labelExpression:r.labelExpression,labelExpressionInfo:r.labelExpressionInfo?{expression:r.labelExpressionInfo.expression}:null,symbol:!!r.symbol,where:r.where}}),{fieldIndex:a}=s;return{...F(r,e,l),fieldIndex:a,target:i,index:n}}function q(r,i,n=!1){const s={indexCount:0,fields:{}},a="featureReduction"in r&&r.featureReduction,o=a?"aggregate":"feature";if("sublayers"in r){const e={type:"subtype",subtypeField:r.subtypeField,renderers:{}},i={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:i,mesh:{matcher:e,aggregateMatcher:null,labels:a,sortKey:null}},d=new Set;let f=0;for(const{renderer:c,subtypeCode:p,labelingInfo:m,labelsVisible:y}of r.sublayers){const r=Q(s,o,c,n),u=H(s,o,c),g=y&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new t(v,"Visual variables are currently not supported for subtype layers");if("dictionary"===r.type)throw new t(v,"Dictionary renderer is not supported in subtype layers");if("subtype"===r.type)throw new t(v,"Nested subtype renderers is not supported");if(l(u)&&"subtype"===u.type)throw new t(v,"Nested subtype storage is not supported");if(l(u)&&"dot-density"===u.type)throw new t(v,"Dot density attributes are not supported in subtype layers");if(d.has(p))throw new t(v,"Subtype codes for sublayers must be unique");d.add(p),e.renderers[p]=r,i.mapping[p]=u,g&&(a.classes[p]=g.map((e=>$(c,s,e,"feature",f++,n))))}return u}if("heatmap"===r.renderer.type){const{blurRadius:e,fieldOffset:t,field:i}=r.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{blurRadius:e,fieldOffset:t,field:P(s,{target:o,field:i,resultType:"numeric"}).field}}}{const i=[],l="aggregate"===o?b(i,r.renderer,a,null):r.renderer;G(s,i);const u=Q(s,o,l,n);let d=null;const f=H(s,o,l),c=h(r.geometryType);let p=r.labelsVisible&&r.labelingInfo||[],m=[];if(a){if("selection"===a.type)throw new t(v,"Mapview does not support `selection` reduction type",a);if(a.symbol){const t=new e({symbol:a.symbol,visualVariables:"visualVariables"in l?l.visualVariables:null});d=Q(s,o,t,n)}m=a&&a.labelsVisible&&a.labelingInfo||[]}p=R(p,c),m=R(m,c);let y=0;const g=[...p.map((e=>$(l,s,e,"feature",y++,n))),...m.map((e=>$(l,s,e,"aggregate",y++,n)))],x=A(s,r.orderBy);return{type:"symbol",target:o,attributes:s,aggregateFields:i,storage:f,mesh:{matcher:u,labels:{type:"simple",classes:g},aggregateMatcher:d,sortKey:x}}}}function A(e,r){if(s(r)||!r.length)return null;r.length>1&&x.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],n="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:n};if(i.valueExpression){return{fieldIndex:U(e,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:n}}return x.error(new t(v,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function G(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,outStatistic:n}=i,{statisticType:l,onStatisticField:s}=n;let a=null,o=null,u=null;const d="numeric",f="feature";if("onStatisticValueExpression"in n){o=U(e,{type:"expression",target:f,valueExpression:n.onStatisticValueExpression,resultType:d}).fieldIndex}else if("onStatisticNormalizationField"in n){a=U(e,{type:"field",target:f,field:s,resultType:d}).field,u=n.onStatisticNormalizationField}else{a=U(e,{type:"field",target:f,field:s,resultType:d}).field}U(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:a,inNormalizationField:u,inFieldIndex:o,statisticType:l})}}function H(e,t,r){switch(r.type){case"dot-density":return W(e,t,r.attributes);case"simple":case"class-breaks":case"unique-value":case"dictionary":return X(e,t,r.visualVariables);case"heatmap":return null}}function W(e,t,r){if(!r||!r.length)return{type:"dot-density",mapping:[],target:t};return{type:"dot-density",mapping:r.map(((r,i)=>{const{field:n,fieldIndex:l}=P(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i,field:n,fieldIndex:l}})),target:t}}function X(e,t,r){if(!r||!r.length)return{type:"visual-variable",mapping:[],target:t};const i={storage:!0},n="numeric";return{type:"visual-variable",mapping:g(r).map((r=>{var l;const s=f(r.type),{field:a,fieldIndex:o}=P(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:null!=(l=r.valueRepresentation)?l:null};case"color":return{type:"color",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:a,fieldIndex:o,normalizationField:P(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:a,fieldIndex:o}}})).filter((e=>e)),target:t}}function Q(e,t,r,i=!1){const n=a(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return Y(n,r,"dot-density"===r.type,i);case"class-breaks":return Z(n,t,r,i);case"unique-value":return _(n,t,r,i);case"dictionary":return ee(n,r,i)}}function Y(e,t,r,i=!1){const n=t.getSymbols();return{type:"simple",symbol:F(n.length?n[0]:null,t,i),isDotDensity:r}}function Z(e,t,r,i=!1){const n={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:s,fieldIndex:a}=P(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:n}),o=r.normalizationType,u="log"===o?"esriNormalizeByLog":"percent-of-total"===o?"esriNormalizeByPercentOfTotal":"field"===o?"esriNormalizeByField":null,d=r.classBreakInfos.map((e=>({symbol:F(e.symbol,r,i),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:s,fieldIndex:a,backgroundFillSymbol:F(l,r,i),defaultSymbol:F(r.defaultSymbol,r,i),intervals:d,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:u,isMaxInclusive:r.isMaxInclusive}}function _(e,r,i,n=!1){const l=[],s=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new t(v,"Expected renderer.field to be a string",i);const{field:o,fieldIndex:u}=P(e,{...a,field:i.field,valueExpression:i.valueExpression});for(const t of i.uniqueValueInfos)l.push({value:""+t.value,symbol:F(t.symbol,i,n)});return{type:"map",attributes:e.fields,field:o,fieldIndex:u,field2:P(e,{...a,field:i.field2}).field,field3:P(e,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:F(s,i),defaultSymbol:F(i.defaultSymbol,i),map:l}}function ee(e,t,r=!1){return{type:"dictionary",renderer:t.toJSON()}}export{G as addAggregateFields,Q as createMatcherSchema,M as createSchema,F as createSymbolSchema};
5
+ import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/Renderer.js";import e from"../../../../renderers/SimpleRenderer.js";import"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import t from"../../../../core/Error.js";import r from"../../../../core/has.js";import{clone as i}from"../../../../core/lang.js";import n from"../../../../core/Logger.js";import{isSome as l,isNone as s,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{fromJSON as u}from"../../../../symbols/support/jsonUtils.js";import{WGLGeometryType as d}from"../../engine/webgl/enums.js";import{getVVType as f}from"../../engine/webgl/Utils.js";import{createMaterialKey as c,hydrateMaterialKey as p}from"../../engine/webgl/materialKey/MaterialKey.js";import{getVVFlags as m}from"../../engine/webgl/util/vvFlagUtils.js";import{getPtMaxVVSize as y}from"./support/pixelBuffering.js";import{simplifyVisualVariables as g}from"./support/rendererUtils.js";import{createClusterRenderer as b}from"../support/clusterUtils.js";import{toJSONGeometryType as h}from"../support/util.js";const x=n.getLogger("esri.views.2d.layers.features.schemaUtils"),v="ValidationError",w={esriGeometryPoint:["above-right","above-center","above-left","center-center","center-left","center-right","below-center","below-left","below-right"],esriGeometryPolygon:["always-horizontal"],esriGeometryPolyline:["center-along"],esriGeometryMultipoint:null};function E(e){return p(e)}function I(e){return e}function S(e){if("line-marker"===e.type){var t;return{type:"line-marker",color:null==(t=e.color)?void 0:t.toJSON(),placement:e.placement,style:e.style}}return u(e.toJSON()).toJSON()}function F(e,t,r){if(!e)return null;let i=0,n=!1,s=0;switch(l(t)&&(s=y(t),"visualVariables"in t&&(i=m(t.visualVariables||[]),n="dot-density"===t.type)),e.type){case"simple-fill":case"picture-fill":return V(e,i,n,r);case"simple-marker":case"picture-marker":return j(e,i,s,r);case"simple-line":return z(e,i,r);case"text":return T(e,i,s,r);case"label":return K(e,i,r);case"cim":return{type:"cim",rendererKey:i,data:e.data,maxVVSize:s};case"web-style":return{...S(e),type:"web-style",hash:e.hash(),rendererKey:i,maxVVSize:s};default:throw new Error(`symbol not supported ${e.type}`)}}function V(e,t,r,i){const n=c(d.FILL,t,!1,r),l=i?E(n):n,s=e.clone(),a=s.outline;s.outline=null;const o=[],u={materialKey:l,hash:s.hash(),...S(s)};if(o.push(u),a){const e=c(d.LINE,t,!0,!1),r={materialKey:i?E(e):e,hash:a.hash(),...S(a)};o.push(r)}return{type:"composite-symbol",layers:o,hash:o.reduce(((e,t)=>t.hash+e),"")}}function z(e,t,r){const i=c(d.LINE,t,!1,!1),n=r?E(i):i,l=e.clone(),s=l.marker;l.marker=null;const a=[];if(a.push({materialKey:n,hash:l.hash(),...S(l)}),s){var o;const e=c(d.MARKER,t,!1,!1),i=r?E(e):e;s.color=null!=(o=s.color)?o:l.color,a.push({materialKey:i,hash:s.hash(),lineWidth:l.width,...S(s)})}return{type:"composite-symbol",layers:a,hash:a.reduce(((e,t)=>t.hash+e),"")}}function j(e,t,r,i){const n=c(d.MARKER,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function T(e,t,r,i){const n=c(d.TEXT,t,!1,!1),l=i?E(n):n,s=S(e);return{materialKey:l,hash:e.hash(),...s,angle:e.angle,maxVVSize:r}}function N(e,r){const i=e.labelPlacement,n=w[r];if(!e.symbol)return x.warn("No ILabelClass symbol specified."),!0;if(!n)return x.error(new t("mapview-labeling:unsupported-geometry-type",`Unable to create labels for Feature Layer, ${r} is not supported`)),!0;if(!n.some((e=>e===i))){const t=n[0];i&&x.warn(`Found invalid label placement type ${i} for ${r}. Defaulting to ${t}`),e.labelPlacement=t}return!1}function R(e,t){const r=i(e);return r.some((e=>N(e,t)))?[]:r}function K(e,t,r){const i=e.toJSON(),n=c(d.LABEL,t,!1,!1,i.labelPlacement);return{materialKey:r?E(n):n,hash:e.hash(),...i,labelPlacement:i.labelPlacement}}function M(e){return r("esri-2d-update-debug")&&console.debug("Created new schema",O(e,!0)),O(e)}function O(e,t=!1){try{var r,i;const n=C(e,t),l={};n.map((t=>k(l,e,t)));return{source:{definitionExpression:e.definitionExpression,fields:e.fields.map((e=>e.toJSON())),gdbVersion:e.gdbVersion,historicMoment:null==(r=e.historicMoment)?void 0:r.getTime(),outFields:e.availableFields,pixelBuffer:e.pixelBuffer,spatialReference:e.spatialReference.toJSON(),timeExtent:null==(i=e.timeExtent)?void 0:i.toJSON(),customParameters:e.customParameters},attributes:{fields:{},indexCount:0},processors:n,targets:l}}catch(n){if(n.fieldName===v)return x.error(n),null;throw n}}function k(e,r,i){switch(i.target){case"feature":return void P(e,L(r),i);case"aggregate":{if(!("featureReduction"in r))return;const n=r.featureReduction;if("selection"===n.type)throw new t(v,"Mapview does not support `selection` reduction type",n);return P(e,L(r),i),void J(e,n,i)}}}function B(e,t){for(const r in t){const i=t[r];if(i.target!==e.name)continue;const n=e.attributes[r];n?(n.context.mesh=n.context.mesh||i.context.mesh,n.context.storage=n.context.storage||i.context.storage):e.attributes[r]=i}return e}function L(e){var t,r,i,n,l;return[null!=(t=null==(r=e.filter)?void 0:r.toJSON())?t:null,null!=(i=null==(n=e.effect)||null==(l=n.filter)?void 0:l.toJSON())?i:null]}function P(e,t,r){return e.feature||(e.feature={name:"feature",input:"source",filters:t,attributes:{}}),B(e.feature,r.attributes.fields),e}function J(e,t,r){return e.aggregate||(e.aggregate={name:"aggregate",input:"feature",filters:null,attributes:{},params:{clusterRadius:o(t.clusterRadius/2),clusterPixelBuffer:64*Math.ceil(o(t.clusterMaxSize)/64),fields:r.aggregateFields}}),B(e.aggregate,r.attributes.fields),e}function D(e,t){return t.field?U(e,{...t,type:"field",field:t.field}):t.valueExpression?U(e,{...t,type:"expression",valueExpression:t.valueExpression}):{field:null,fieldIndex:null}}function U(e,t){switch(t.type){case"expression":{const r=I(t.valueExpression);if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"label-expression":{const r=I(JSON.stringify(t.label));if(!e.fields[r]){const i=e.indexCount++;e.fields[r]={...t,name:r,fieldIndex:i}}return{fieldIndex:e.fields[r].fieldIndex}}case"field":{const r=t.field;return"aggregate"===t.target&&e.fields[r]||(e.fields[r]={...t,name:r}),{field:r}}case"statistic":return e.fields[t.name]={...t},{field:t.name}}}function C(e,t=!1){const r=new Array;let i=0;return r.push(q(e,i++,t)),r}function $(e,t,r,i,n,l=!1){const s=U(t,{type:"label-expression",target:i,context:{mesh:!0},resultType:"string",label:{labelExpression:r.labelExpression,labelExpressionInfo:r.labelExpressionInfo?{expression:r.labelExpressionInfo.expression}:null,symbol:!!r.symbol,where:r.where}}),{fieldIndex:a}=s;return{...F(r,e,l),fieldIndex:a,target:i,index:n}}function q(r,i,n=!1){const s={indexCount:0,fields:{}},a="featureReduction"in r&&r.featureReduction,o=a?"aggregate":"feature";if("sublayers"in r){const e={type:"subtype",subtypeField:r.subtypeField,renderers:{}},i={type:"subtype",mapping:{},target:"feature"},a={type:"subtype",classes:{}},u={type:"symbol",target:"feature",aggregateFields:[],attributes:s,storage:i,mesh:{matcher:e,aggregateMatcher:null,labels:a,sortKey:null}},d=new Set;let f=0;for(const{renderer:c,subtypeCode:p,labelingInfo:m,labelsVisible:y}of r.sublayers){const r=Q(s,o,c,n),u=H(s,o,c),g=y&&m;if("visualVariables"in c&&c.visualVariables&&c.visualVariables.length)throw new t(v,"Visual variables are currently not supported for subtype layers");if("dictionary"===r.type)throw new t(v,"Dictionary renderer is not supported in subtype layers");if("subtype"===r.type)throw new t(v,"Nested subtype renderers is not supported");if(l(u)&&"subtype"===u.type)throw new t(v,"Nested subtype storage is not supported");if(l(u)&&"dot-density"===u.type)throw new t(v,"Dot density attributes are not supported in subtype layers");if(d.has(p))throw new t(v,"Subtype codes for sublayers must be unique");d.add(p),e.renderers[p]=r,i.mapping[p]=u,g&&(a.classes[p]=g.map((e=>$(c,s,e,"feature",f++,n))))}return u}if("heatmap"===r.renderer.type){const{blurRadius:e,fieldOffset:t,field:i}=r.renderer;return{type:"heatmap",aggregateFields:[],attributes:s,target:o,storage:null,mesh:{blurRadius:e,fieldOffset:t,field:D(s,{target:o,field:i,resultType:"numeric"}).field}}}{const i=[],l="aggregate"===o?b(i,r.renderer,a,null):r.renderer;G(s,i);const u=Q(s,o,l,n);let d=null;const f=H(s,o,l),c=h(r.geometryType);let p=r.labelsVisible&&r.labelingInfo||[],m=[];if(a){if("selection"===a.type)throw new t(v,"Mapview does not support `selection` reduction type",a);if(a.symbol){const t=new e({symbol:a.symbol,visualVariables:"visualVariables"in l?l.visualVariables:null});d=Q(s,o,t,n)}m=a&&a.labelsVisible&&a.labelingInfo||[]}p=R(p,c),m=R(m,c);let y=0;const g=[...p.map((e=>$(l,s,e,"feature",y++,n))),...m.map((e=>$(l,s,e,"aggregate",y++,n)))],x=A(s,r.orderBy);return{type:"symbol",target:o,attributes:s,aggregateFields:i,storage:f,mesh:{matcher:u,labels:{type:"simple",classes:g},aggregateMatcher:d,sortKey:x}}}}function A(e,r){if(s(r)||!r.length)return null;r.length>1&&x.warn(`Layer rendering currently only supports ordering by 1 orderByInfo, but found ${r.length}. All but the first will be discarded`);const i=r[0],n="ascending"===i.order?"asc":"desc";if(i.field)return{field:i.field,order:n};if(i.valueExpression){return{fieldIndex:U(e,{type:"expression",target:"feature",valueExpression:i.valueExpression,resultType:"numeric"}).fieldIndex,order:n}}return x.error(new t(v,"Expected to find a field or valueExpression for OrderByInfo",i)),null}function G(e,t){const r={mesh:!0,storage:!0};for(const i of t){const{name:t,outStatistic:n}=i,{statisticType:l,onStatisticField:s}=n;let a=null,o=null,u=null;const d="numeric",f="feature";if("onStatisticValueExpression"in n){o=U(e,{type:"expression",target:f,valueExpression:n.onStatisticValueExpression,resultType:d}).fieldIndex}else if("onStatisticNormalizationField"in n){a=U(e,{type:"field",target:f,field:s,resultType:d}).field,u=n.onStatisticNormalizationField}else{a=U(e,{type:"field",target:f,field:s,resultType:d}).field}U(e,{type:"statistic",target:"aggregate",name:t,context:r,inField:a,inNormalizationField:u,inFieldIndex:o,statisticType:l})}}function H(e,t,r){switch(r.type){case"dot-density":return W(e,t,r.attributes);case"simple":case"class-breaks":case"unique-value":case"dictionary":return X(e,t,r.visualVariables);case"heatmap":return null}}function W(e,t,r){if(!r||!r.length)return{type:"dot-density",mapping:[],target:t};return{type:"dot-density",mapping:r.map(((r,i)=>{const{field:n,fieldIndex:l}=D(e,{valueExpression:r.valueExpression,field:r.field,resultType:"numeric",target:t});return{binding:i,field:n,fieldIndex:l}})),target:t}}function X(e,t,r){if(!r||!r.length)return{type:"visual-variable",mapping:[],target:t};const i={storage:!0},n="numeric";return{type:"visual-variable",mapping:g(r).map((r=>{var l;const s=f(r.type),{field:a,fieldIndex:o}=D(e,{target:t,valueExpression:r.valueExpression,field:r.field,context:i,resultType:n});switch(r.type){case"size":return"$view.scale"===r.valueExpression?null:{type:"size",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field,valueRepresentation:null!=(l=r.valueRepresentation)?l:null};case"color":return{type:"color",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"opacity":return{type:"opacity",binding:s,field:a,fieldIndex:o,normalizationField:D(e,{target:t,field:r.normalizationField,context:i,resultType:n}).field};case"rotation":return{type:"rotation",binding:s,field:a,fieldIndex:o}}})).filter((e=>e)),target:t}}function Q(e,t,r,i=!1){const n=a(e,{indexCount:0,fields:{}});switch(r.type){case"simple":case"dot-density":return Y(n,r,"dot-density"===r.type,i);case"class-breaks":return Z(n,t,r,i);case"unique-value":return _(n,t,r,i);case"dictionary":return ee(n,r,i)}}function Y(e,t,r,i=!1){const n=t.getSymbols();return{type:"simple",symbol:F(n.length?n[0]:null,t,i),isDotDensity:r}}function Z(e,t,r,i=!1){const n={mesh:!0,use:"renderer.field"},l=r.backgroundFillSymbol,{field:s,fieldIndex:a}=D(e,{target:t,field:r.field,valueExpression:r.valueExpression,resultType:"numeric",context:n}),o=r.normalizationType,u="log"===o?"esriNormalizeByLog":"percent-of-total"===o?"esriNormalizeByPercentOfTotal":"field"===o?"esriNormalizeByField":null,d=r.classBreakInfos.map((e=>({symbol:F(e.symbol,r,i),min:e.minValue,max:e.maxValue}))).sort(((e,t)=>e.min-t.min));return{type:"interval",attributes:e.fields,field:s,fieldIndex:a,backgroundFillSymbol:F(l,r,i),defaultSymbol:F(r.defaultSymbol,r,i),intervals:d,normalizationField:r.normalizationField,normalizationTotal:r.normalizationTotal,normalizationType:u,isMaxInclusive:r.isMaxInclusive}}function _(e,r,i,n=!1){const l=[],s=i.backgroundFillSymbol,a={target:r,context:{mesh:!0},resultType:"string"};if(i.field&&"string"!=typeof i.field)throw new t(v,"Expected renderer.field to be a string",i);const{field:o,fieldIndex:u}=D(e,{...a,field:i.field,valueExpression:i.valueExpression});for(const t of i.uniqueValueInfos)l.push({value:""+t.value,symbol:F(t.symbol,i,n)});return{type:"map",attributes:e.fields,field:o,fieldIndex:u,field2:D(e,{...a,field:i.field2}).field,field3:D(e,{...a,field:i.field3}).field,fieldDelimiter:i.fieldDelimiter,backgroundFillSymbol:F(s,i),defaultSymbol:F(i.defaultSymbol,i),map:l}}function ee(e,t,r=!1){return{type:"dictionary",renderer:t.toJSON()}}export{G as addAggregateFields,Q as createMatcherSchema,M as createSchema,F as createSymbolSchema};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../request.js";import t from"../../../../../core/Error.js";import r from"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{isSome as i,unwrapOr as a,isNone as o}from"../../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as u}from"../../../../../core/promiseUtils.js";import{createSourceAdapter as c}from"../controllers/support/sourceAdapters.js";import{DataTileSource as d}from"./DataTileSource.js";import{QueueProcessor as l}from"../../../../support/QueueProcessor.js";const p=s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource"),y=4;class h extends d{constructor(e){super(e),this.type="feature",this.mode="on-demand",this._adapter=c(e.serviceInfo),this._queue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{query:i,signal:s});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,e)}}),this._patchQueue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{query:i,signal:s});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,e)}})}destroy(){super.destroy(),this._adapter.destroy(),this._queue.destroy(),this._patchQueue.destroy()}get updating(){return!!this._queue.length||Array.from(this._subscriptions.values()).some((e=>!e.done))}get maxRecordCountFactor(){const{query:e}=this._serviceInfo.capabilities;return e.supportsMaxRecordCountFactor?y:null}get maxPageSize(){var e;const{query:t}=this._serviceInfo.capabilities;return(null!=(e=t.maxRecordCount)?e:8e3)*a(this.maxRecordCountFactor,1)}get pageSize(){return Math.min(8e3,this.maxPageSize)}enableEvent(e,t){}subscribe(e){super.subscribe(e);const r=this._subscriptions.get(e.id);this._fetchDataTile(e).catch((r=>{u(r)||p.error(new t("mapview-query-error","Encountered error when fetching tile",{tile:e,error:r}))})).then((()=>r.end()))}unsubscribe(e){super.unsubscribe(e)}readers(e){return this._subscriptions.get(e).readers()}async query(e){return this._adapter.executeQuery(e)}async queryLastEditDate(){const t=this._serviceInfo.source,r={...t.query,f:"json"};return(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate}createTileQuery(e,t={}){var r;const s=this.createQuery(t);return s.quantizationParameters=null!=(r=t.quantizationParameters)?r:e.getQuantizationParameters(),s.resultType="tile",s.geometry=e.extent,s.quantizationParameters&&"esriGeometryPolyline"===this._serviceInfo.geometryType&&(s.maxAllowableOffset=e.resolution),s}async _executePatchQuery(e,t,r,s){const a=t.clone();a.outFields=[this._serviceInfo.objectIdField,...r],a.returnCentroid=!1,a.returnGeometry=!1;const o=i(a.start)?a.start/8e3:0,n=s.signal;return this._patchQueue.push({tile:e,query:a,signal:n,depth:o})}async _resend(e,t){const{query:r,message:s}=e,a=i(r.outFields)?r.outFields:[],u=this._queryInfo.outFields,c=u.filter((e=>-1===a.indexOf(e)));if(o(s.addOrUpdate))this._onMessage({...s,type:"append"});else if(c.length)try{const e=this._subscriptions.get(s.id).tile,i=await this._executePatchQuery(e,r,c,t);n(t),r.outFields=u,s.addOrUpdate.joinAttributes(i),this._onMessage({...s,end:s.end,type:"append"})}catch(d){}else this._onMessage({...s,type:"append"})}async _resendSubscription(e){if(e.empty)return this._onMessage({id:e.tile.id,addOrUpdate:null,end:!1,type:"append"});const t=e.signal;for(const r of e.requests.done)await this._resend(r,{signal:t});return i(e.edits)?this._onMessage(e.edits):void 0}async resend(){const e=Array.from(this._subscriptions.values());await Promise.all(e.map((e=>this._resendSubscription(e))))}}export{h as BaseFeatureSource};
5
+ import e from"../../../../../request.js";import t from"../../../../../core/Error.js";import r from"../../../../../core/has.js";import s from"../../../../../core/Logger.js";import{isSome as i,unwrapOr as a,isNone as o}from"../../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as u}from"../../../../../core/promiseUtils.js";import{createSourceAdapter as c}from"../controllers/support/sourceAdapters.js";import{DataTileSource as d}from"./DataTileSource.js";import{QueueProcessor as l}from"../../../../support/QueueProcessor.js";const p=s.getLogger("esri.views.2d.layers.features.sources.BaseFeatureSource"),h=4;class y extends d{constructor(e){super(e),this.type="feature",this.mode="on-demand",this._adapter=c(e.serviceInfo),this._queue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{signal:s,query:{...i,...this._schema.customParameters}});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,{...e,query:this._schema.customParameters})}}),this._patchQueue=new l({concurrency:8,process:async e=>{if(n(e),i(e.tile)){const t=e.tile.key.id,{signal:s}=e,i=r("esri-tiles-debug")?{tile:t.replace(/\//g,"."),depth:e.depth}:void 0,a=await this._adapter.executeQuery(e.query,{signal:s,query:{...i,...this._schema.customParameters}});return a.level=e.tile.key.level,a}return this._adapter.executeQuery(e.query,{...e,query:this._schema.customParameters})}})}destroy(){super.destroy(),this._adapter.destroy(),this._queue.destroy(),this._patchQueue.destroy()}get updating(){return!!this._queue.length||Array.from(this._subscriptions.values()).some((e=>!e.done))}get maxRecordCountFactor(){const{query:e}=this._serviceInfo.capabilities;return e.supportsMaxRecordCountFactor?h:null}get maxPageSize(){var e;const{query:t}=this._serviceInfo.capabilities;return(null!=(e=t.maxRecordCount)?e:8e3)*a(this.maxRecordCountFactor,1)}get pageSize(){return Math.min(8e3,this.maxPageSize)}enableEvent(e,t){}subscribe(e){super.subscribe(e);const r=this._subscriptions.get(e.id);this._fetchDataTile(e).catch((r=>{u(r)||p.error(new t("mapview-query-error","Encountered error when fetching tile",{tile:e,error:r}))})).then((()=>r.end()))}unsubscribe(e){super.unsubscribe(e)}readers(e){return this._subscriptions.get(e).readers()}async query(e){return this._adapter.executeQuery(e,{query:this._schema.customParameters})}async queryLastEditDate(){const t=this._serviceInfo.source,r={...t.query,f:"json"};return(await e(t.path,{query:r,responseType:"json"})).data.editingInfo.lastEditDate}createTileQuery(e,t={}){var r;const s=this.createQuery(t);return s.quantizationParameters=null!=(r=t.quantizationParameters)?r:e.getQuantizationParameters(),s.resultType="tile",s.geometry=e.extent,s.quantizationParameters&&"esriGeometryPolyline"===this._serviceInfo.geometryType&&(s.maxAllowableOffset=e.resolution),s}async _executePatchQuery(e,t,r,s){const a=t.clone();a.outFields=[this._serviceInfo.objectIdField,...r],a.returnCentroid=!1,a.returnGeometry=!1;const o=i(a.start)?a.start/8e3:0,n=s.signal;return this._patchQueue.push({tile:e,query:a,signal:n,depth:o})}async _resend(e,t){const{query:r,message:s}=e,a=i(r.outFields)?r.outFields:[],u=this._queryInfo.outFields,c=u.filter((e=>-1===a.indexOf(e)));if(o(s.addOrUpdate))this._onMessage({...s,type:"append"});else if(c.length)try{const e=this._subscriptions.get(s.id).tile,i=await this._executePatchQuery(e,r,c,t);n(t),r.outFields=u,s.addOrUpdate.joinAttributes(i),this._onMessage({...s,end:s.end,type:"append"})}catch(d){}else this._onMessage({...s,type:"append"})}async _resendSubscription(e){if(e.empty)return this._onMessage({id:e.tile.id,addOrUpdate:null,end:!1,type:"append"});const t=e.signal;for(const r of e.requests.done)await this._resend(r,{signal:t});return i(e.edits)?this._onMessage(e.edits):void 0}async resend(){const e=Array.from(this._subscriptions.values());await Promise.all(e.map((e=>this._resendSubscription(e))))}}export{y as BaseFeatureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../TimeExtent.js";import s from"../../../../../core/Evented.js";import t from"../../../../../core/has.js";import{isSome as i}from"../../../../../core/maybe.js";import{createResolver as r,eachAlwaysValues as o,eachAlways as n}from"../../../../../core/promiseUtils.js";import{diff as c,hasDiff as u,hasDiffAny as h}from"../../../../../core/accessorSupport/diffUtils.js";import d from"../../../../../rest/support/Query.js";import{DataTileSubscription as a}from"./DataTileSubscription.js";function l(e,s){const t=new Set;return e&&e.forEach((e=>t.add(e))),s&&s.forEach((e=>t.add(e))),t.has("*")?["*"]:Array.from(t)}class p{constructor(e){this.events=new s,this._resolver=r(),this._didEdit=!1,this._subscriptions=new Map,this._outSR=e.outSR,this._serviceInfo=e.serviceInfo,this._onTileUpdateMessage=e.onMessage}destroy(){}async _onMessage(e){var s;const t=this._subscriptions.get(e.id);if(!t)return;const i={...e,remove:null!=(s=e.remove)?s:[],status:e.status};return this._onTileUpdateMessage(i,t.options)}update(s,i){var r;const o=i.fields.length;i.outFields=l(null==(r=this._schema)?void 0:r.outFields,i.outFields),i.outFields=i.outFields.length>=.75*o?["*"]:i.outFields,i.outFields.sort();const n=c(this._schema,i);if(!n)return;t("esri-2d-update-debug")&&console.debug("Applying Update - Source:",n);const d="orderByFields"in this._serviceInfo&&this._serviceInfo.orderByFields?this._serviceInfo.orderByFields:this._serviceInfo.objectIdField+" ASC",a={returnCentroid:t("esri-2d-query-centroid-enabled")&&"esriGeometryPolygon"===this._serviceInfo.geometryType,returnGeometry:!0,timeReferenceUnknownClient:"stream"!==this._serviceInfo.type&&this._serviceInfo.timeReferenceUnknownClient,outFields:i.outFields,outSpatialReference:this._outSR,orderByFields:[d],where:i.definitionExpression||"1=1",gdbVersion:i.gdbVersion,historicMoment:i.historicMoment,timeExtent:e.fromJSON(i.timeExtent)},p=this._schema&&u(n,"outFields");this._schema&&h(n,["timeExtent","definitionExpression","gdbVersion","historicMoment"])&&(s.why.mesh.push("Layer filter changed"),s.why.source.push("Layer filter changed"),s.mesh=!0,s.source=!0,s.queryFilter=!0),p&&(s.why.source.push("Layer required fields changed"),s.source=!0),c(a,this._queryInfo)&&(this._queryInfo=a),this._schema=i,this._resolver.resolve()}whenInitialized(){return this._resolver.promise}async applyUpdate(e){if(e.queryFilter||e.source&&this._didEdit)return this.refresh(),void(this._didEdit=!1);this._subscriptions.forEach((s=>s.applyUpdate(e))),await this.resend()}refresh(){for(const e of this._tiles())this.unsubscribe(e),this.subscribe(e)}subscribe(e){const s=new a(e);this._subscriptions.set(e.id,s)}unsubscribe(e){const s=this.get(e.id);i(s)&&s.abort(),this._subscriptions.delete(e.id)}createQuery(e={}){const s=this._queryInfo.historicMoment?new Date(this._queryInfo.historicMoment):null;return new d({...this._queryInfo,historicMoment:s,...e})}get(e){return this._subscriptions.has(e)?this._subscriptions.get(e):null}async queryLastEditDate(){throw new Error("Service does not support query type")}async query(e){throw new Error("Service does not support query")}*_tiles(){const e=Array.from(this._subscriptions.values());for(const s of e)yield s.tile}async edit(e,s){const t=Array.from(this._subscriptions.values()),i=t.map((({tile:e})=>e));for(const r of t)r.removeIds(s);if(e.length){const t=i.map((s=>{const t=this.createTileQuery(s);return t.objectIds=e,{tile:s,query:t}})).map((async({tile:e,query:s})=>({tile:e,result:await this.query(s),query:s}))),r=(await o(t)).map((async({tile:t,result:i})=>{if(!i.hasFeatures&&!s.length&&!e.length)return;const r=this._subscriptions.get(t.key.id);r&&r.edit(i,e)}));await n(r)}this._didEdit=!0}}export{p as DataTileSource};
5
+ import e from"../../../../../TimeExtent.js";import s from"../../../../../core/Evented.js";import t from"../../../../../core/has.js";import{isSome as r}from"../../../../../core/maybe.js";import{createResolver as i,eachAlwaysValues as o,eachAlways as n}from"../../../../../core/promiseUtils.js";import{diff as c,hasDiff as u,hasDiffAny as a}from"../../../../../core/accessorSupport/diffUtils.js";import h from"../../../../../rest/support/Query.js";import{DataTileSubscription as d}from"./DataTileSubscription.js";function l(e,s){const t=new Set;return e&&e.forEach((e=>t.add(e))),s&&s.forEach((e=>t.add(e))),t.has("*")?["*"]:Array.from(t)}class m{constructor(e){this.events=new s,this._resolver=i(),this._didEdit=!1,this._subscriptions=new Map,this._outSR=e.outSR,this._serviceInfo=e.serviceInfo,this._onTileUpdateMessage=e.onMessage}destroy(){}async _onMessage(e){var s;const t=this._subscriptions.get(e.id);if(!t)return;const r={...e,remove:null!=(s=e.remove)?s:[],status:e.status};return this._onTileUpdateMessage(r,t.options)}update(s,r){var i;const o=r.fields.length;r.outFields=l(null==(i=this._schema)?void 0:i.outFields,r.outFields),r.outFields=r.outFields.length>=.75*o?["*"]:r.outFields,r.outFields.sort();const n=c(this._schema,r);if(!n)return;t("esri-2d-update-debug")&&console.debug("Applying Update - Source:",n);const h="orderByFields"in this._serviceInfo&&this._serviceInfo.orderByFields?this._serviceInfo.orderByFields:this._serviceInfo.objectIdField+" ASC",d={returnCentroid:t("esri-2d-query-centroid-enabled")&&"esriGeometryPolygon"===this._serviceInfo.geometryType,returnGeometry:!0,timeReferenceUnknownClient:"stream"!==this._serviceInfo.type&&this._serviceInfo.timeReferenceUnknownClient,outFields:r.outFields,outSpatialReference:this._outSR,orderByFields:[h],where:r.definitionExpression||"1=1",gdbVersion:r.gdbVersion,historicMoment:r.historicMoment,timeExtent:e.fromJSON(r.timeExtent),customParameters:r.customParameters},m=this._schema&&u(n,"outFields");this._schema&&a(n,["timeExtent","definitionExpression","gdbVersion","historicMoment","customParameters"])&&(s.why.mesh.push("Layer filter and/or custom parameters changed"),s.why.source.push("Layer filter and/or custom parameters changed"),s.mesh=!0,s.source=!0,s.queryFilter=!0),m&&(s.why.source.push("Layer required fields changed"),s.source=!0),c(d,this._queryInfo)&&(this._queryInfo=d),this._schema=r,this._resolver.resolve()}whenInitialized(){return this._resolver.promise}async applyUpdate(e){if(e.queryFilter||e.source&&this._didEdit)return this.refresh(),void(this._didEdit=!1);this._subscriptions.forEach((s=>s.applyUpdate(e))),await this.resend()}refresh(){for(const e of this._tiles())this.unsubscribe(e),this.subscribe(e)}subscribe(e){const s=new d(e);this._subscriptions.set(e.id,s)}unsubscribe(e){const s=this.get(e.id);r(s)&&s.abort(),this._subscriptions.delete(e.id)}createQuery(e={}){const s=this._queryInfo.historicMoment?new Date(this._queryInfo.historicMoment):null;return new h({...this._queryInfo,historicMoment:s,...e})}get(e){return this._subscriptions.has(e)?this._subscriptions.get(e):null}async queryLastEditDate(){throw new Error("Service does not support query type")}async query(e){throw new Error("Service does not support query")}*_tiles(){const e=Array.from(this._subscriptions.values());for(const s of e)yield s.tile}async edit(e,s){const t=Array.from(this._subscriptions.values()),r=t.map((({tile:e})=>e));for(const i of t)i.removeIds(s);if(e.length){const t=r.map((s=>{const t=this.createTileQuery(s);return t.objectIds=e,{tile:s,query:t}})).map((async({tile:e,query:s})=>({tile:e,result:await this.query(s),query:s}))),i=(await o(t)).map((async({tile:t,result:r})=>{if(!r.hasFeatures&&!s.length&&!e.length)return;const i=this._subscriptions.get(t.key.id);i&&i.edit(r,e)}));await n(i)}this._didEdit=!0}}export{m as DataTileSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as r}from"../../../../core/maybe.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/Logger.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";let a=class extends i{constructor(){super(...arguments),this.container=null,this.layer=null,this.tileSize=null,this.type="raster",this.useWebGLForProcessing=!0}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&this._canUseMajorityInterpolationOnDataSource())}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}async updateTileSource(e,t){const{bandIds:o}=this.layer,s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:a,symbolizerParams:n,globalSymbolizerParams:l,suspended:c,coords:p,resolution:u}=t,{bitmap:d}=e;if([d.x,d.y]=p,d.resolution=u,a&&r(a)&&r(a.pixelBlock)){const e={extent:a.extent,pixelBlock:a.pixelBlock};if(d.rawPixelData=e,i)d.source=a.pixelBlock,d.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===(null==l?void 0:l.type)?l:null);d.source=r,d.isRendereredSource=!0}d.symbolizerParameters=i?n:null,i?d.transformGrid||(d.transformGrid=a.transformGrid):d.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();d.source=e,d.symbolizerParameters=i?n:null,d.transformGrid=null}d.bandIds=o,d.width=this.tileSize[0],d.height=this.tileSize[1],d.interpolation=s,d.suspended=c,d.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:o,global:s}=t,{bandIds:i}=this.layer,a=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:l}=e,{rawPixelData:c}=l;!n&&r(c)?(l.source=await this.layer.applyRenderer(c,"stretch"===(null==s?void 0:s.type)?s:null),l.isRendereredSource=!0):(l.isRendereredSource&&r(c)&&(l.source=c.pixelBlock),l.isRendereredSource=!1),l.symbolizerParameters=n?s||o:null,l.bandIds=i,l.interpolation=a,l.suspended=!1}install(e,r){this.container=new s(r.tileInfoView),this.container.isCustomTilingScheme=r.isCustomTilingScheme,e.addChild(this.container)}uninstall(){this.container.removeAllChildren(),this.container.remove()}_canUseMajorityInterpolationOnDataSource(){const{bandCount:e,attributeTable:r,colormap:t,pixelType:o}=this.layer.rasterInfo;return 1===e&&(null!=r||null!=t||"u8"===o||"s8"===o)}_getLayerInterpolation(){const e=this.layer.renderer.type;if("raster-colormap"===e||"unique-value"===e||"class-breaks"===e)return"nearest";const{interpolation:r}=this.layer,{renderer:t}=this.layer;return"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===r||"cubic"===r?"bilinear":"nearest":r}};e([t()],a.prototype,"container",void 0),e([t()],a.prototype,"layer",void 0),e([t()],a.prototype,"tileSize",void 0),e([t()],a.prototype,"type",void 0),e([t()],a.prototype,"useWebGLForProcessing",void 0),a=e([o("esri.views.2d.layers.imagery.ImageryTileView2D")],a);var n=a;export{n as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{isSome as r}from"../../../../core/maybe.js";import{property as t}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/Logger.js";import{subclass as o}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";let l=class extends i{constructor(){super(...arguments),this.container=null,this.layer=null,this.tileSize=null,this.type="raster",this.useWebGLForProcessing=!0}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&this._canUseMajorityInterpolationOnDataSource())}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}async updateTileSource(e,t){const{bandIds:o}=this.layer,s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:l,symbolizerParams:a,globalSymbolizerParams:n,suspended:c,coords:p,resolution:u}=t,{bitmap:d}=e;if([d.x,d.y]=p,d.resolution=u,l&&r(l)&&r(l.pixelBlock)){const e={extent:l.extent,pixelBlock:l.pixelBlock};if(d.rawPixelData=e,i)d.source=l.pixelBlock,d.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===(null==n?void 0:n.type)?n:null);d.source=r,d.isRendereredSource=!0}d.symbolizerParameters=i?a:null,i?d.transformGrid||(d.transformGrid=l.transformGrid):d.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();d.source=e,d.symbolizerParameters=i?a:null,d.transformGrid=null}d.bandIds=i?o:null,d.width=this.tileSize[0],d.height=this.tileSize[1],d.interpolation=s,d.suspended=c,d.invalidateTexture()}async updateTileSymbolizerParameters(e,t){const{local:o,global:s}=t,{bandIds:i}=this.layer,l=this._getLayerInterpolation(),a=this.canUseWebGLForProcessing(),{bitmap:n}=e,{rawPixelData:c}=n;!a&&r(c)?(n.source=await this.layer.applyRenderer(c,"stretch"===(null==s?void 0:s.type)?s:null),n.isRendereredSource=!0):(n.isRendereredSource&&r(c)&&(n.source=c.pixelBlock),n.isRendereredSource=!1),n.symbolizerParameters=a?s||o:null,n.bandIds=a?i:null,n.interpolation=l,n.suspended=!1}install(e,r){this.container=new s(r.tileInfoView),this.container.isCustomTilingScheme=r.isCustomTilingScheme,e.addChild(this.container)}uninstall(){this.container.removeAllChildren(),this.container.remove()}_canUseMajorityInterpolationOnDataSource(){const{bandCount:e,attributeTable:r,colormap:t,pixelType:o}=this.layer.rasterInfo;return 1===e&&(null!=r||null!=t||"u8"===o||"s8"===o)}_getLayerInterpolation(){const e=this.layer.renderer.type;if("raster-colormap"===e||"unique-value"===e||"class-breaks"===e)return"nearest";const{interpolation:r}=this.layer,{renderer:t}=this.layer;return"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===r||"cubic"===r?"bilinear":"nearest":r}};e([t()],l.prototype,"container",void 0),e([t()],l.prototype,"layer",void 0),e([t()],l.prototype,"tileSize",void 0),e([t()],l.prototype,"type",void 0),e([t()],l.prototype,"useWebGLForProcessing",void 0),l=e([o("esri.views.2d.layers.imagery.ImageryTileView2D")],l);var a=l;export{a 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.21/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{init as t}from"../../core/watchUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import r from"./ScaleRanges.js";import n from"../Slider/SliderViewModel.js";let c=class extends(i(a)){constructor(e){super(e),this.layer=null,this.scaleRanges=r.fromScaleRange({minScale:0,maxScale:0}),this.sliderViewModel=(()=>{const{max:e}=this._getSliderIndexRange(this.scaleRanges.length-1);return new n({precision:10,min:0,max:e,values:[0,e]})})()}initialize(){this.handles.add([t(this,"sliderViewModel.values",(()=>{if(!this._hasTiledLayer())return;const[e,a]=this.sliderViewModel.values,i=this.mapScaleToSlider(this._getTiledLayerMaxScale()),t=this.mapScaleToSlider(this._getTiledLayerMinScale());(a>i||e<t)&&(this.sliderViewModel.values=[Math.max(e,t),Math.min(a,i)])})),t(this,"layer.loaded",(async()=>{const{layer:e,view:a}=this;if(e)if(a&&await a.when(),await e.when(),"minScale"in e&&"maxScale"in e){const{minScale:a,maxScale:i}=e;this.set({minScale:a,maxScale:i})}else this.set({minScale:void 0,maxScale:void 0})}))])}get maxScale(){const e=this.mapSliderToScale(this.sliderViewModel.values[1]);return this._handleEdgeScale("max",e)}set maxScale(e){this._setMaxScaleOnSlider(e)}get maxScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.max)}set maxScaleLimit(e){this._setSliderRange({maxScale:e,minScale:this.minScaleLimit})}get minScale(){const e=this.mapSliderToScale(this.sliderViewModel.values[0]);return this._handleEdgeScale("min",e)}set minScale(e){this._setMinScaleOnSlider(e)}get minScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.min)}set minScaleLimit(e){this._setSliderRange({maxScale:this.maxScaleLimit,minScale:e})}get state(){const{view:e,layer:a}=this;return!e&&!a||!e&&a&&a.loaded||!a&&e&&e.ready||e&&e.ready&&a&&a.loaded?"ready":"disabled"}set view(e){this._set("view",e)}mapScaleToSlider(e){const a=this.scaleRanges.scaleToRangeIndex(e),i=this.scaleRanges.findScaleRangeByIndex(a),{maxScale:t,minScale:l}=i,{max:s,min:r}=this._getSliderIndexRange(a);return this._mapToRange(e,l,t,r,s)}mapSliderToScale(e){const a=this.scaleRanges.findScaleRangeByIndex(e),{maxScale:i,minScale:t}=a,{max:l,min:s}=this._getSliderIndexRange(e);return this._mapToRange(e,s,l,t,i)}_setSliderRange(e){this.scaleRanges=r.fromScaleRange(e);const{max:a}=this._getSliderIndexRange(this.scaleRanges.length-1);this.sliderViewModel.max=a,this.sliderViewModel.min=0,this.notifyChange("maxScaleLimit"),this.notifyChange("minScaleLimit")}_getSliderIndexRange(e){const a=Math.floor(e);return{min:a,max:a+.99999}}_mapToRange(e,a,i,t,l){return t+(e-a)*(l-t)/(i-a)}_setMaxScaleOnSlider(e){const{scaleRanges:a,sliderViewModel:i}=this;if(void 0!==e){const t=this.mapScaleToSlider(this._constrainMaxScaleToLayer(a.clampMaxScale(e)));i.values=[i.values[0],t]}}_setMinScaleOnSlider(e){const{scaleRanges:a,sliderViewModel:i}=this;if(void 0!==e){const t=this.mapScaleToSlider(this._constrainMinScaleToLayer(a.clampMinScale(e)));i.values=[t,i.values[1]]}}_constrainMinScaleToLayer(e){const{scaleRanges:a}=this;if(this._hasTiledLayer()){const{firstRange:i}=a,t=this._getTiledLayerMinScale(),l=.85;e=this._mapToRange(e,i.maxScale,i.minScale,0,1)>l||e>t?t:e}return e}_constrainMaxScaleToLayer(e){if(this._hasTiledLayer()){const a=this._getTiledLayerMaxScale();e=e<a?a:e}return e}_handleEdgeScale(e,a){const i="max"===e?"maxScale":"minScale",t=this.scaleRanges[i]===a?0:a;return Number(t.toFixed(6))}_getLayerLODS(){var e,a;return"imagery-tile"===(null==(e=this.layer)?void 0:e.type)&&"Raster"===(null==(a=this.layer.raster)?void 0:a.tileType)?null:this.get("layer.tileInfo.lods")}_getTiledLayerMinScale(){const e=this._getLayerLODS();return this.scaleRanges.clampMinScale(e[0].scale)}_getTiledLayerMaxScale(){const e=this._getLayerLODS();return e[e.length-1].scale}_hasTiledLayer(){return!!this._getLayerLODS()}};e([l()],c.prototype,"layer",void 0),e([l()],c.prototype,"maxScale",null),e([l()],c.prototype,"maxScaleLimit",null),e([l()],c.prototype,"minScale",null),e([l()],c.prototype,"minScaleLimit",null),e([l()],c.prototype,"scaleRanges",void 0),e([l()],c.prototype,"sliderViewModel",void 0),e([l({readOnly:!0})],c.prototype,"state",null),e([l()],c.prototype,"view",null),c=e([s("esri.widgets.ScaleRangeSlider.ScaleRangeSliderViewModel")],c);var o=c;export{o as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import a from"../../core/Accessor.js";import{HandleOwnerMixin as i}from"../../core/HandleOwner.js";import{init as t}from"../../core/watchUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import r from"./ScaleRanges.js";import n from"../Slider/SliderViewModel.js";let c=class extends(i(a)){constructor(e){super(e),this.layer=null,this.scaleRanges=r.fromScaleRange({minScale:0,maxScale:0}),this.sliderViewModel=(()=>{const{max:e}=this._getSliderIndexRange(this.scaleRanges.length-1);return new n({precision:10,min:0,max:e,values:[0,e]})})()}initialize(){this.handles.add([t(this,"sliderViewModel.values",(()=>{if(!this._hasTiledLayer())return;const[e,a]=this.sliderViewModel.values,i=this.mapScaleToSlider(this._getTiledLayerMaxScale()),t=this.mapScaleToSlider(this._getTiledLayerMinScale());(a>i||e<t)&&(this.sliderViewModel.values=[Math.max(e,t),Math.min(a,i)])})),t(this,"layer.loaded",(async()=>{const{layer:e,view:a}=this;if(e)if(a&&await a.when(),await e.when(),"minScale"in e&&"maxScale"in e){const{minScale:a,maxScale:i}=e;this.set({minScale:a,maxScale:i})}else this.set({minScale:void 0,maxScale:void 0})}))])}get maxScale(){const e=this.mapSliderToScale(this.sliderViewModel.values[1]);return this._normalizeScale("max",e)}set maxScale(e){this._setMaxScaleOnSlider(e)}get maxScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.max)}set maxScaleLimit(e){this._setSliderRange({maxScale:e,minScale:this.minScaleLimit})}get minScale(){const e=this.mapSliderToScale(this.sliderViewModel.values[0]);return this._normalizeScale("min",e)}set minScale(e){this._setMinScaleOnSlider(e)}get minScaleLimit(){return this.mapSliderToScale(this.sliderViewModel.min)}set minScaleLimit(e){this._setSliderRange({maxScale:this.maxScaleLimit,minScale:e})}get state(){const{view:e,layer:a}=this;return!e&&!a||!e&&a&&a.loaded||!a&&e&&e.ready||e&&e.ready&&a&&a.loaded?"ready":"disabled"}set view(e){this._set("view",e)}mapScaleToSlider(e){const a=this.scaleRanges.scaleToRangeIndex(e),i=this.scaleRanges.findScaleRangeByIndex(a),{maxScale:t,minScale:l}=i,{max:s,min:r}=this._getSliderIndexRange(a);return this._mapToRange(e,l,t,r,s)}mapSliderToScale(e){const a=this.scaleRanges.findScaleRangeByIndex(e),{maxScale:i,minScale:t}=a,{max:l,min:s}=this._getSliderIndexRange(e);return this._mapToRange(e,s,l,t,i)}_setSliderRange(e){this.scaleRanges=r.fromScaleRange(e);const{max:a}=this._getSliderIndexRange(this.scaleRanges.length-1);this.sliderViewModel.max=a,this.sliderViewModel.min=0,this.notifyChange("maxScaleLimit"),this.notifyChange("minScaleLimit")}_getSliderIndexRange(e){const a=Math.floor(e);return{min:a,max:a+.99999}}_mapToRange(e,a,i,t,l){return t+(e-a)*(l-t)/(i-a)}_setMaxScaleOnSlider(e){const{scaleRanges:a,sliderViewModel:i}=this;if(void 0!==e){const t=this.mapScaleToSlider(this._constrainMaxScaleToLayer(a.clampMaxScale(e)));i.values=[i.values[0],t]}}_setMinScaleOnSlider(e){const{scaleRanges:a,sliderViewModel:i}=this;if(void 0!==e){const t=this.mapScaleToSlider(this._constrainMinScaleToLayer(a.clampMinScale(e)));i.values=[t,i.values[1]]}}_constrainMinScaleToLayer(e){const{scaleRanges:a}=this;if(this._hasTiledLayer()){const{firstRange:i}=a,t=this._getTiledLayerMinScale(),l=.85;e=this._mapToRange(e,i.maxScale,i.minScale,0,1)>l||e>t?t:e}return e}_constrainMaxScaleToLayer(e){if(this._hasTiledLayer()){const a=this._getTiledLayerMaxScale();e=e<a?a:e}return e}_normalizeScale(e,a){const i="max"===e?"maxScale":"minScale",t=this._hasTiledLayer()?"min"===e?this._getTiledLayerMinScale():this._getTiledLayerMaxScale():this.scaleRanges[i],l=1e-6,s=0===a||t===a||Math.abs(t-a)<=l;return Number((s?0:a).toFixed(6))}_getLayerLODS(){var e,a;return"imagery-tile"===(null==(e=this.layer)?void 0:e.type)&&"Raster"===(null==(a=this.layer.raster)?void 0:a.tileType)?null:this.get("layer.tileInfo.lods")}_getTiledLayerMinScale(){const e=this._getLayerLODS();return this.scaleRanges.clampMinScale(e[0].scale)}_getTiledLayerMaxScale(){const e=this._getLayerLODS();return e[e.length-1].scale}_hasTiledLayer(){return!!this._getLayerLODS()}};e([l()],c.prototype,"layer",void 0),e([l()],c.prototype,"maxScale",null),e([l()],c.prototype,"maxScaleLimit",null),e([l()],c.prototype,"minScale",null),e([l()],c.prototype,"minScaleLimit",null),e([l()],c.prototype,"scaleRanges",void 0),e([l()],c.prototype,"sliderViewModel",void 0),e([l({readOnly:!0})],c.prototype,"state",null),e([l()],c.prototype,"view",null),c=e([s("esri.widgets.ScaleRangeSlider.ScaleRangeSliderViewModel")],c);var o=c;export{o as default};