@arcgis/core 5.1.0-next.61 → 5.1.0-next.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/4dbbf59c79d9e72f20ee.js +1 -0
  3. package/assets/esri/core/workers/chunks/71326d16b5cc35c3ff7f.js +1 -0
  4. package/assets/esri/core/workers/chunks/{c69fefe9d51ac7c2b0a6.js → 75f7c1f600c4051bc905.js} +1 -1
  5. package/assets/esri/core/workers/chunks/ed60b5eaa5765bfcb99c.js +1 -0
  6. package/config.js +1 -1
  7. package/interfaces.d.ts +14 -0
  8. package/kernel.js +1 -1
  9. package/layers/mixins/ArcGISImageService.js +1 -1
  10. package/layers/raster/datasets/BaseRaster.js +1 -1
  11. package/layers/raster/datasets/ImageAuxRaster.js +1 -1
  12. package/layers/raster/datasets/ImageServerRaster.js +1 -1
  13. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  14. package/layers/raster/formats/JpgPlus.js +1 -1
  15. package/layers/raster/formats/RasterCodec.js +1 -1
  16. package/package.json +1 -1
  17. package/popup/Feature.d.ts +8 -3
  18. package/popup/Feature.js +1 -1
  19. package/popup/Features.d.ts +663 -0
  20. package/popup/Features.js +2 -0
  21. package/popup/support/FeatureAbilities.d.ts +30 -0
  22. package/popup/support/FeatureAbilities.js +2 -0
  23. package/support/revision.js +1 -1
  24. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  25. package/widgets/Feature/FeatureViewModel.d.ts +2 -1
  26. package/widgets/Feature/FeatureViewModel.js +1 -1
  27. package/widgets/Feature.js +1 -1
  28. package/widgets/Popup/actionUtils.js +1 -1
  29. package/assets/esri/core/workers/chunks/5f3f50fec18d1642fdf9.js +0 -1
  30. package/assets/esri/core/workers/chunks/b42487c6a989e11a2559.js +0 -1
  31. package/assets/esri/core/workers/chunks/dba479176db0a23c8034.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{IdentifiableMixin as n}from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,initial as f,when as m,on as _}from"../../core/reactiveUtils.js";import{throttle as y}from"../../core/throttle.js";import{property as g,cast as b,subclass as v}from"../../core/accessorSupport/decorators.js";import w from"../../geometry/Point.js";import A from"../../geometry/SpatialReference.js";import I from"../../popup/content/TextContent.js";import{compileExpressionInfos as x,formatArcadeValue as M}from"../../popup/support/arcadeFeatureUtils.js";import{preLayerQueryCallback as T,preRequestCallback as F,createFieldInfoMap as C,getAllFieldInfos as E,getSourceLayer as V,querySourceLayer as k,queryUpdatedFeature as j,isRelatableFeatureSupportedLayer as P,isAssociatedFeatureSupportedLayer as R,substituteFieldsInLinksAndAttributes as L,isExpressionField as O,isRelatedField as N,formatEditInfo as U,graphicCallback as Z,formatAttributes as B}from"../../popup/support/featureUtils.js";import{queryLayerInfos as H,queryRelatedFeatures as S,setRelatedFeatures as D,getRelatedFieldInfo as G,createRelatedInfo as q,updateRelatedInfo as K}from"../../popup/support/relatedFeatureUtils.js";import{system as z}from"../../time/constants.js";import Q from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import J from"./FeatureContent/FeatureContentViewModel.js";import W from"./FeatureExpression/FeatureExpressionViewModel.js";import X from"./FeatureFields/FeatureFieldsViewModel.js";import Y from"./FeatureMedia/FeatureMediaViewModel.js";import $ from"./FeatureRelationship/FeatureRelationshipViewModel.js";import ee from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var te;const ie=1,se="content-view-models",oe="relationship-view-models",re="association-view-models",ae={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let ne=class extends(n(s)){static{te=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...ae},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=y(this._graphicChanged,()=>this.notifyChange("waitingForContent"),ie,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=y(this._evaluateExpressionAttributes,()=>this.notifyChange("waitingForContent"),ie,this),this.addHandles([u(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),f),m(()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(T,F)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return C(E(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return V(this.graphic)}castAbilities(e){return{...ae,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??z}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof Y&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof Y&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof Y&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await k({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r(async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await j({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),x(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}})}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map((e,t)=>this._compileContentElement(e,t)).filter(o):"string"==typeof e?this._compileText(new I({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(oe),this.removeHandles(se),this.contentViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach(t=>{e.some(e=>this._matchesFeature(e,t))||e.add(new te({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))}),e.forEach(i=>{const s=t?.find(e=>this._matchesFeature(i,e));s||e.remove(i)})}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!P(n))return;const c=new $({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(_(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),oe),e}_matchesGlobalFeature(e,t){return e.association.equals(t.association)}_setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach((i,s)=>{const o=t.get(s);o?i.forEach(t=>{o.find(e=>this._matchesGlobalFeature(t,e))||(i.remove(t),0===i.length&&e.delete(s))}):(i.removeAll(),e.delete(s))}),t.forEach((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new te({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!R(a))return;const p=new ee({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u(()=>p.associationFeatures.values(),()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map))],re),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new W({expressionInfo:i,graphic:s,interceptor:te.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),f),se),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r,attachmentKeywords:a,attachmentTypes:n}=e;return this.contentViewModels[t]=new Q({attachmentKeywords:a,attachmentTypes:n,graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new J({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:L({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:L({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=!!e?.fieldInfos,a=e?.fieldInfos||i?.fieldInfos,n=a?.filter(({fieldName:e})=>!!e&&(O(e)||N(e)||o.hasOwnProperty(e))),l=i?.expressionInfos,{description:p,title:c}=e;return{attributes:o,expressionInfos:l,fieldInfos:n,isContentFieldInfos:r,graphic:this.graphic,layer:this._sourceLayer,...this._compileTitleAndDesc({title:c,description:p})}}_compileFields(e,t){const i=e.clone(),s=new X(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,graphic:s,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new Y(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=L({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new J(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?U(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return L({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Z({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?Z({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r(async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:te.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?M(e):e]).catch(()=>[t,void 0])):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=B({attributes:{...l,...e.attributes},fieldInfoMap:n,fieldInfos:s?.fieldInfos,graphic:o,layer:a,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=B({attributes:{...n,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:s,isContentFieldInfos:!0,layer:r,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:B({attributes:a,fieldInfoMap:r,fieldInfos:l,graphic:i,layer:o,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})}),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,E(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter(e=>!!e.fieldName&&N(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await H({relatedInfos:s,layer:r},i);Object.keys(n).forEach(e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)});const l=await S({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{D(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=G(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||q(o,t);a&&(K({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([g()],ne.prototype,"_error",void 0),e([g()],ne.prototype,"_graphicChangedTask",void 0),e([g()],ne.prototype,"_evaluateExpressionAttributesTask",void 0),e([g()],ne.prototype,"_associationVMAbortController",void 0),e([g({readOnly:!0})],ne.prototype,"_effectivePopupTemplate",null),e([g({readOnly:!0})],ne.prototype,"_fieldInfoMap",null),e([g({readOnly:!0})],ne.prototype,"_sourceLayer",null),e([g()],ne.prototype,"abilities",void 0),e([b("abilities")],ne.prototype,"castAbilities",null),e([g({readOnly:!0})],ne.prototype,"content",void 0),e([g({readOnly:!0})],ne.prototype,"contentViewModels",void 0),e([g()],ne.prototype,"description",void 0),e([g({type:Boolean})],ne.prototype,"defaultPopupTemplateEnabled",void 0),e([g({readOnly:!0})],ne.prototype,"isFeatureFromTable",null),e([g({readOnly:!0})],ne.prototype,"state",null),e([g({readOnly:!0})],ne.prototype,"formattedAttributes",void 0),e([g({type:t})],ne.prototype,"graphic",void 0),e([g({readOnly:!0})],ne.prototype,"lastEditInfo",void 0),e([g({type:w})],ne.prototype,"location",void 0),e([g({readOnly:!0})],ne.prototype,"relatedInfos",void 0),e([g({type:A})],ne.prototype,"spatialReference",null),e([g()],ne.prototype,"timeZone",null),e([g({readOnly:!0})],ne.prototype,"title",void 0),e([g()],ne.prototype,"map",null),e([g({readOnly:!0})],ne.prototype,"waitingForContent",null),e([g()],ne.prototype,"view",void 0),ne=te=e([v("esri.widgets.Feature.FeatureViewModel")],ne);export{ne as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedModule as n}from"../../core/deprecate.js";import{IdentifiableMixin as l}from"../../core/Identifiable.js";import p from"../../core/Logger.js";import{abortMaybe as c}from"../../core/maybe.js";import{eachAlways as d,isAbortError as h,throwIfAborted as u}from"../../core/promiseUtils.js";import{watch as f,initial as m,when as _,on as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b,cast as w,subclass as v}from"../../core/accessorSupport/decorators.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import x from"../../popup/content/TextContent.js";import{compileExpressionInfos as M,formatArcadeValue as T}from"../../popup/support/arcadeFeatureUtils.js";import{preLayerQueryCallback as F,preRequestCallback as C,createFieldInfoMap as E,getAllFieldInfos as V,getSourceLayer as k,querySourceLayer as j,queryUpdatedFeature as P,isRelatableFeatureSupportedLayer as R,isAssociatedFeatureSupportedLayer as L,substituteFieldsInLinksAndAttributes as O,isExpressionField as U,isRelatedField as N,formatEditInfo as Z,graphicCallback as D,formatAttributes as B}from"../../popup/support/featureUtils.js";import{queryLayerInfos as H,queryRelatedFeatures as S,setRelatedFeatures as G,getRelatedFieldInfo as q,createRelatedInfo as z,updateRelatedInfo as K}from"../../popup/support/relatedFeatureUtils.js";import{system as W}from"../../time/constants.js";import Q from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import J from"./FeatureContent/FeatureContentViewModel.js";import X from"./FeatureExpression/FeatureExpressionViewModel.js";import Y from"./FeatureFields/FeatureFieldsViewModel.js";import $ from"./FeatureMedia/FeatureMediaViewModel.js";import ee from"./FeatureRelationship/FeatureRelationshipViewModel.js";import te from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";var ie;const se=1,oe="content-view-models",re="relationship-view-models",ae="association-view-models",ne={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let le=class extends(l(s)){static{ie=this}constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...ne},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.graphic=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,()=>this.notifyChange("waitingForContent"),se,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,()=>this.notifyChange("waitingForContent"),se,this),e?.suppressDeprecationWarning||n(p.getLogger(this),"esri.widgets.Feature.FeatureViewModel",{version:"5.1",replacement:"Use the Feature component or the @arcgis/core/popup/Feature module instead.",warnOnce:!0}),this.addHandles([f(()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone],()=>this._graphicChangedThrottled(),m),_(()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]},([e])=>this._evaluateExpressionAttributesThrottled(e))])}normalizeCtorArgs(e){const{suppressDeprecationWarning:t,...i}=e??{};return i}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=c(this._graphicChangedTask),this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}static{this.interceptor=new i(F,C)}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(V(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return k(this.graphic)}castAbilities(e){return{...ne,...e}}get isFeatureFromTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??W}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof $&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof $&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof $&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await j({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._graphicChangedTask=c(this._graphicChangedTask),this._graphicChangedTask=r(async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await P({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await d([this._getContent(),this._getTitle()]),[,{value:n}]=await d([this._checkForRelatedFeatures({signal:e}),M(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw h(i)||(this._error=i,p.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}})}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map((e,t)=>this._compileContentElement(e,t)).filter(o):"string"==typeof e?this._compileText(new x({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(re),this.removeHandles(oe),this.contentViewModels.forEach(e=>e&&!e.destroyed&&e.destroy()),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach(t=>{e.some(e=>this._matchesFeature(e,t))||e.add(new ie({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))}),e.forEach(i=>{const s=t?.find(e=>this._matchesFeature(i,e));s||e.remove(i)})}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!R(n))return;const c=new ee({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(y(()=>c.relatedFeatures,"change",()=>this._setRelatedFeaturesViewModels(c)),re),e}_matchesGlobalFeature(e,t){return e.association.equals(t.association)}_setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach((i,s)=>{const o=t.get(s);o?i.forEach(t=>{o.find(e=>this._matchesGlobalFeature(t,e))||(i.remove(t),0===i.length&&e.delete(s))}):(i.removeAll(),e.delete(s))}),t.forEach((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e,t)=>{if(!l.some(t=>this._matchesGlobalFeature(t,e))){const{association:a,feature:n,terminalName:p,title:c}=e;l.add({title:c,association:a,featureViewModel:new ie({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:n}),terminalName:p},t)}}),e.set(n,l)})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!L(a))return;const p=new te({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([f(()=>p.associationFeatures.values(),()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map))],ae),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new X({expressionInfo:i,graphic:s,interceptor:ie.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(f(()=>l.contentElementViewModel,()=>this._setExpressionContentVM(l,t),m),oe),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r,attachmentKeywords:a,attachmentTypes:n}=e;return this.contentViewModels[t]=new Q({attachmentKeywords:a,attachmentTypes:n,graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new J({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:O({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:O({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=!!e?.fieldInfos,a=e?.fieldInfos||i?.fieldInfos,n=a?.filter(({fieldName:e})=>!!e&&(U(e)||N(e)||o.hasOwnProperty(e))),l=i?.expressionInfos,{description:p,title:c}=e;return{attributes:o,expressionInfos:l,fieldInfos:n,isContentFieldInfos:r,graphic:this.graphic,layer:this._sourceLayer,...this._compileTitleAndDesc({title:c,description:p})}}_compileFields(e,t){const i=e.clone(),s=new Y(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,graphic:s,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new $(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=O({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new J(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?Z(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return O({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?D({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?D({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=c(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r(async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:l}=this;try{if(!o)return;let p;if(null!=i){const e=[];for(const[t,p]of i.expressions.entries())null!=p?e.push(p.evaluate({graphic:o,interceptor:ie.interceptor,location:l,map:r,options:{signal:s},spatialReference:n,view:a}).then(e=>[t,"string"==typeof e?T(e):e]).catch(()=>[t,void 0])):e.push(Promise.resolve([t,void 0]));p=Object.fromEntries(await Promise.all(e)),u(s)}this._expressionAttributes=p,this._graphicExpressionAttributes={...o.attributes,...p},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){h(c)||(this._error=c,p.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}})}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=B({attributes:{...l,...e.attributes},fieldInfoMap:n,fieldInfos:s?.fieldInfos,graphic:o,layer:a,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=B({attributes:{...n,...e.attributes},fieldInfoMap:a,fieldInfos:e.fieldInfos,graphic:s,isContentFieldInfos:!0,layer:r,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:B({attributes:a,fieldInfoMap:r,fieldInfos:l,graphic:i,layer:o,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})}),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,V(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter(e=>!!e.fieldName&&N(e.fieldName));if(!a?.length)return;t.forEach(e=>this._configureRelatedInfo(e,r));const n=await H({relatedInfos:s,layer:r},i);Object.keys(n).forEach(e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)});const l=await S({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach(e=>{G(l[e]?.value,s.get(e.toString()))})}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=q(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||z(o,t);a&&(K({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};e([b()],le.prototype,"_error",void 0),e([b()],le.prototype,"_graphicChangedTask",void 0),e([b()],le.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],le.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],le.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],le.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],le.prototype,"_sourceLayer",null),e([b()],le.prototype,"abilities",void 0),e([w("abilities")],le.prototype,"castAbilities",null),e([b({readOnly:!0})],le.prototype,"content",void 0),e([b({readOnly:!0})],le.prototype,"contentViewModels",void 0),e([b()],le.prototype,"description",void 0),e([b({type:Boolean})],le.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],le.prototype,"isFeatureFromTable",null),e([b({readOnly:!0})],le.prototype,"state",null),e([b({readOnly:!0})],le.prototype,"formattedAttributes",void 0),e([b({type:t})],le.prototype,"graphic",void 0),e([b({readOnly:!0})],le.prototype,"lastEditInfo",void 0),e([b({type:A})],le.prototype,"location",void 0),e([b({readOnly:!0})],le.prototype,"relatedInfos",void 0),e([b({type:I})],le.prototype,"spatialReference",null),e([b()],le.prototype,"timeZone",null),e([b({readOnly:!0})],le.prototype,"title",void 0),e([b()],le.prototype,"map",null),e([b({readOnly:!0})],le.prototype,"waitingForContent",null),e([b()],le.prototype,"view",void 0),le=ie=e([v("esri.widgets.Feature.FeatureViewModel")],le);export{le as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../Graphic.js";import{substitute as i}from"../intl.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{watch as r,initial as o}from"../core/reactiveUtils.js";import{property as l,cast as d,subclass as a}from"../core/accessorSupport/decorators.js";import c from"../geometry/Point.js";import p from"./Widget.js";import u from"./Feature/FeatureAttachments.js";import m from"./Feature/FeatureContent.js";import h from"./Feature/FeatureExpression.js";import y from"./Feature/FeatureFields.js";import v from"./Feature/FeatureMedia.js";import g from"./Feature/FeatureRelationship.js";import w from"./Feature/FeatureUtilityNetworkAssociations.js";import f from"./Feature/FeatureViewModel.js";import{css as _}from"./Feature/resources.js";import{FeatureContentMixin as M}from"./Feature/support/FeatureContentMixin.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as F}from"./support/Heading.js";import{tsx as W,messageBundle as C}from"./support/widget.js";const j={title:!0,content:!0,lastEditedInfo:!0};let k=class extends(M(p)){constructor(e,t){super(e,t),this._contentWidgets=[],this.flowType="feature",this.flowItems=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.visibleElements={...j},this.viewModel=new f,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{s(n.getLogger(this),"Feature","arcgis-feature",{version:"4.34"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles(r(()=>this.viewModel?.contentViewModels,()=>this._setupContentWidgets(),o))}loadDependencies(){return E({notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyContentWidgets()}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get isTable(){return this.viewModel.isFeatureFromTable}get icon(){return"polygon"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get title(){return this.viewModel.title}castVisibleElements(e){return{...j,...e}}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}setActiveMedia(e,t){return this.viewModel.setActiveMedia(e,t)}nextMedia(e){return this.viewModel.nextMedia(e)}previousMedia(e){return this.viewModel.previousMedia(e)}render(){const{state:e}=this.viewModel,t=W("div",{class:_.container,key:"container"},this._renderTitle(),"error"===e?this._renderError():"loading"===e?this._renderLoading():this._renderContentContainer());return W("div",{class:this.classes(_.base,b.widget)},t)}_renderError(){const{messagesCommon:e,messages:t,visibleElements:i}=this;return W("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0,scale:"s"},i.title?W("div",{key:"error-title",slot:"title"},e.errorMessage):null,W("div",{key:"error-message",slot:"message"},t.loadingError))}_renderLoading(){return W("div",{class:_.loadingSpinnerContainer,key:"loading-container"},W("calcite-loader",{inline:!0,label:""}))}_renderContentContainer(){const{visibleElements:e}=this;return e.content?W("div",{class:_.main},[this._renderContent(),this._renderLastEditInfo()]):null}_renderTitle(){const{visibleElements:e,title:t}=this;return e.title?W(F,{class:_.title,innerHTML:t,level:this.headingLevel}):null}_renderContent(){const e=this.viewModel.content,t="content";if(!e)return null;if(Array.isArray(e))return e.length?W("div",{class:_.contentNode,key:`${t}-content-elements`},e.map(this._renderContentElement,this)):null;if("string"==typeof e){const e=this._contentWidgets[0];return!e||e.destroyed?null:W("div",{class:this.classes(_.contentNode,_.contentNodeText),key:`${t}-content`},e.render())}return this.renderNodeContent(e)}_renderContentElement(e,t){const{visibleElements:i}=this;if("boolean"!=typeof i.content&&!i.content?.[e.type])return null;switch(e.type){case"attachments":return this._renderAttachments(t);case"custom":return this._renderCustom(e,t);case"fields":return this._renderFields(t);case"media":return this._renderMedia(t);case"text":return this._renderText(e,t);case"expression":return this._renderExpression(t);case"relationship":return this._renderRelationship(t);case"utility-network-associations":return this._renderAssociation(t);default:return null}}_renderAttachments(e){const t=this._contentWidgets[e];if(!t||t.destroyed)return null;const{state:i,attachmentInfos:s}=t.viewModel;return"loading"===i||s.length>0?W("div",{class:this.classes(_.contentElement),key:this._buildKey("attachments-element",e)},t.render()):null}_renderRelationship(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("relationship-element",e)},t.render()):null}_renderAssociation(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("utility-network-association-element",e)},t.render()):null}_renderExpression(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&t.viewModel.contentElement?W("div",{class:_.contentElement,key:this._buildKey("expression-element",e)},t.render()):null}_renderCustom(e,t){const{creator:i}=e,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:_.contentElement,key:this._buildKey("custom-element",t)},s.render()):null}_renderFields(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("fields-element",e)},t.render())}_renderMedia(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("media-element",e)},t.render())}_renderLastEditInfo(){const{visibleElements:e,messages:t}=this,{lastEditInfo:s}=this.viewModel;if(!s||!e.lastEditedInfo)return null;const{date:n,user:r}=s,o="edit"===s.type?r?t.lastEditedByUser:t.lastEdited:r?t.lastCreatedByUser:t.lastCreated,l=i(o,{date:n,user:r});return W("div",{class:this.classes(_.lastEditedInfo,_.contentElement),key:"edit-info-element"},l)}_renderText(e,t){const i=e.text,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:this.classes(_.contentElement,_.text),key:this._buildKey("text-element",t)},s.render()):null}_buildKey(e,...t){return`${e}__${this.viewModel?.graphic?.uid||"0"}-${t.join("-")}`}_destroyContentWidget(e){e&&(e.viewModel=null,!e.destroyed&&e.destroy())}_destroyContentWidgets(){this._contentWidgets.forEach(e=>this._destroyContentWidget(e)),this._contentWidgets=[]}_setupContentWidgets(){this._destroyContentWidgets();const{headingLevel:e,visibleElements:t,flowItems:i,viewModel:s}=this,n=s?.content,{contentViewModels:r}=s;if(Array.isArray(n))n.forEach((n,o)=>{if("attachments"===n.type&&(this._contentWidgets[o]=new u({displayType:n.displayType,headingLevel:t.title&&e<6?e+1:e,viewModel:r[o]})),"fields"===n.type&&(this._contentWidgets[o]=new y({viewModel:r[o]})),"media"===n.type&&(this._contentWidgets[o]=new v({viewModel:r[o]})),"text"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"custom"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"expression"===n.type&&(this._contentWidgets[o]=new h({viewModel:r[o]})),"relationship"===n.type){const e=new g({flowItems:i,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=e}if("utility-network-associations"===n.type){const e=async e=>{const{viewModel:n,listType:r,title:o}=e;if(!i)return;n.activeAssociationType=r;const{default:l}=await import("./Feature/FeatureUtilityNetworkAssociationList.js"),d=new l({viewModel:n,parentFeatureViewModel:s,listType:r,title:o,featureVisibleElements:t,description:s.title,flowItems:i});i.push(d)},n=new w({flowItems:i,onSelectAssociationType:e,parentFeatureViewModel:s,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=n}},this);else{const e=r[0];e&&!e.destroyed&&(this._contentWidgets[0]=new m({viewModel:e}))}this.scheduleRender()}};e([l()],k.prototype,"flowType",void 0),e([l({type:t})],k.prototype,"graphic",null),e([l()],k.prototype,"defaultPopupTemplateEnabled",null),e([l()],k.prototype,"flowItems",void 0),e([l()],k.prototype,"headingLevel",void 0),e([l({readOnly:!0})],k.prototype,"isTable",null),e([l()],k.prototype,"icon",null),e([l()],k.prototype,"label",null),e([l({type:c})],k.prototype,"location",null),e([l(),C("esri/widgets/Feature/t9n/Feature")],k.prototype,"messages",void 0),e([l(),C("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([l()],k.prototype,"spatialReference",null),e([l()],k.prototype,"timeZone",null),e([l({readOnly:!0})],k.prototype,"title",null),e([l()],k.prototype,"visibleElements",void 0),e([d("visibleElements")],k.prototype,"castVisibleElements",null),e([l()],k.prototype,"map",null),e([l()],k.prototype,"view",null),e([l({type:f})],k.prototype,"viewModel",void 0),k=e([a("esri.widgets.Feature")],k);export{k as default};
2
+ import{__decorate as e}from"tslib";import t from"../Graphic.js";import{substitute as i}from"../intl.js";import{deprecateWidget as s}from"../core/deprecate.js";import n from"../core/Logger.js";import{watch as r,initial as o}from"../core/reactiveUtils.js";import{property as l,cast as d,subclass as a}from"../core/accessorSupport/decorators.js";import c from"../geometry/Point.js";import p from"./Widget.js";import u from"./Feature/FeatureAttachments.js";import m from"./Feature/FeatureContent.js";import h from"./Feature/FeatureExpression.js";import y from"./Feature/FeatureFields.js";import v from"./Feature/FeatureMedia.js";import g from"./Feature/FeatureRelationship.js";import w from"./Feature/FeatureUtilityNetworkAssociations.js";import f from"./Feature/FeatureViewModel.js";import{css as _}from"./Feature/resources.js";import{FeatureContentMixin as M}from"./Feature/support/FeatureContentMixin.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as b}from"./support/globalCss.js";import{Heading as F}from"./support/Heading.js";import{tsx as W,messageBundle as C}from"./support/widget.js";const j={title:!0,content:!0,lastEditedInfo:!0};let k=class extends(M(p)){constructor(e,t){super(e,t),this._contentWidgets=[],this.flowType="feature",this.flowItems=null,this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.visibleElements={...j},this.viewModel=new f({suppressDeprecationWarning:!0}),!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{s(n.getLogger(this),"Feature","arcgis-feature",{version:"4.34"})})}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...i}=e;return i}initialize(){this.addHandles(r(()=>this.viewModel?.contentViewModels,()=>this._setupContentWidgets(),o))}loadDependencies(){return E({notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}destroy(){this._destroyContentWidgets()}get graphic(){return this.viewModel.graphic}set graphic(e){this.viewModel.graphic=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get isTable(){return this.viewModel.isFeatureFromTable}get icon(){return"polygon"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get title(){return this.viewModel.title}castVisibleElements(e){return{...j,...e}}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}setActiveMedia(e,t){return this.viewModel.setActiveMedia(e,t)}nextMedia(e){return this.viewModel.nextMedia(e)}previousMedia(e){return this.viewModel.previousMedia(e)}render(){const{state:e}=this.viewModel,t=W("div",{class:_.container,key:"container"},this._renderTitle(),"error"===e?this._renderError():"loading"===e?this._renderLoading():this._renderContentContainer());return W("div",{class:this.classes(_.base,b.widget)},t)}_renderError(){const{messagesCommon:e,messages:t,visibleElements:i}=this;return W("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0,scale:"s"},i.title?W("div",{key:"error-title",slot:"title"},e.errorMessage):null,W("div",{key:"error-message",slot:"message"},t.loadingError))}_renderLoading(){return W("div",{class:_.loadingSpinnerContainer,key:"loading-container"},W("calcite-loader",{inline:!0,label:""}))}_renderContentContainer(){const{visibleElements:e}=this;return e.content?W("div",{class:_.main},[this._renderContent(),this._renderLastEditInfo()]):null}_renderTitle(){const{visibleElements:e,title:t}=this;return e.title?W(F,{class:_.title,innerHTML:t,level:this.headingLevel}):null}_renderContent(){const e=this.viewModel.content,t="content";if(!e)return null;if(Array.isArray(e))return e.length?W("div",{class:_.contentNode,key:`${t}-content-elements`},e.map(this._renderContentElement,this)):null;if("string"==typeof e){const e=this._contentWidgets[0];return!e||e.destroyed?null:W("div",{class:this.classes(_.contentNode,_.contentNodeText),key:`${t}-content`},e.render())}return this.renderNodeContent(e)}_renderContentElement(e,t){const{visibleElements:i}=this;if("boolean"!=typeof i.content&&!i.content?.[e.type])return null;switch(e.type){case"attachments":return this._renderAttachments(t);case"custom":return this._renderCustom(e,t);case"fields":return this._renderFields(t);case"media":return this._renderMedia(t);case"text":return this._renderText(e,t);case"expression":return this._renderExpression(t);case"relationship":return this._renderRelationship(t);case"utility-network-associations":return this._renderAssociation(t);default:return null}}_renderAttachments(e){const t=this._contentWidgets[e];if(!t||t.destroyed)return null;const{state:i,attachmentInfos:s}=t.viewModel;return"loading"===i||s.length>0?W("div",{class:this.classes(_.contentElement),key:this._buildKey("attachments-element",e)},t.render()):null}_renderRelationship(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("relationship-element",e)},t.render()):null}_renderAssociation(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&this.flowItems?W("div",{class:_.contentElement,key:this._buildKey("utility-network-association-element",e)},t.render()):null}_renderExpression(e){const t=this._contentWidgets[e];return t&&!t.destroyed&&t.viewModel.contentElement?W("div",{class:_.contentElement,key:this._buildKey("expression-element",e)},t.render()):null}_renderCustom(e,t){const{creator:i}=e,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:_.contentElement,key:this._buildKey("custom-element",t)},s.render()):null}_renderFields(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("fields-element",e)},t.render())}_renderMedia(e){const t=this._contentWidgets[e];return!t||t.destroyed?null:W("div",{class:_.contentElement,key:this._buildKey("media-element",e)},t.render())}_renderLastEditInfo(){const{visibleElements:e,messages:t}=this,{lastEditInfo:s}=this.viewModel;if(!s||!e.lastEditedInfo)return null;const{date:n,user:r}=s,o="edit"===s.type?r?t.lastEditedByUser:t.lastEdited:r?t.lastCreatedByUser:t.lastCreated,l=i(o,{date:n,user:r});return W("div",{class:this.classes(_.lastEditedInfo,_.contentElement),key:"edit-info-element"},l)}_renderText(e,t){const i=e.text,s=this._contentWidgets[t];return!s||s.destroyed?null:i?W("div",{class:this.classes(_.contentElement,_.text),key:this._buildKey("text-element",t)},s.render()):null}_buildKey(e,...t){return`${e}__${this.viewModel?.graphic?.uid||"0"}-${t.join("-")}`}_destroyContentWidget(e){e&&(e.viewModel=null,!e.destroyed&&e.destroy())}_destroyContentWidgets(){this._contentWidgets.forEach(e=>this._destroyContentWidget(e)),this._contentWidgets=[]}_setupContentWidgets(){this._destroyContentWidgets();const{headingLevel:e,visibleElements:t,flowItems:i,viewModel:s}=this,n=s?.content,{contentViewModels:r}=s;if(Array.isArray(n))n.forEach((n,o)=>{if("attachments"===n.type&&(this._contentWidgets[o]=new u({displayType:n.displayType,headingLevel:t.title&&e<6?e+1:e,viewModel:r[o]})),"fields"===n.type&&(this._contentWidgets[o]=new y({viewModel:r[o]})),"media"===n.type&&(this._contentWidgets[o]=new v({viewModel:r[o]})),"text"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"custom"===n.type&&(this._contentWidgets[o]=new m({viewModel:r[o]})),"expression"===n.type&&(this._contentWidgets[o]=new h({viewModel:r[o]})),"relationship"===n.type){const e=new g({flowItems:i,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=e}if("utility-network-associations"===n.type){const e=async e=>{const{viewModel:n,listType:r,title:o}=e;if(!i)return;n.activeAssociationType=r;const{default:l}=await import("./Feature/FeatureUtilityNetworkAssociationList.js"),d=new l({viewModel:n,parentFeatureViewModel:s,listType:r,title:o,featureVisibleElements:t,description:s.title,flowItems:i});i.push(d)},n=new w({flowItems:i,onSelectAssociationType:e,parentFeatureViewModel:s,featureVisibleElements:t,viewModel:r[o]});this._contentWidgets[o]=n}},this);else{const e=r[0];e&&!e.destroyed&&(this._contentWidgets[0]=new m({viewModel:e}))}this.scheduleRender()}};e([l()],k.prototype,"flowType",void 0),e([l({type:t})],k.prototype,"graphic",null),e([l()],k.prototype,"defaultPopupTemplateEnabled",null),e([l()],k.prototype,"flowItems",void 0),e([l()],k.prototype,"headingLevel",void 0),e([l({readOnly:!0})],k.prototype,"isTable",null),e([l()],k.prototype,"icon",null),e([l()],k.prototype,"label",null),e([l({type:c})],k.prototype,"location",null),e([l(),C("esri/widgets/Feature/t9n/Feature")],k.prototype,"messages",void 0),e([l(),C("esri/t9n/common")],k.prototype,"messagesCommon",void 0),e([l()],k.prototype,"spatialReference",null),e([l()],k.prototype,"timeZone",null),e([l({readOnly:!0})],k.prototype,"title",null),e([l()],k.prototype,"visibleElements",void 0),e([d("visibleElements")],k.prototype,"castVisibleElements",null),e([l()],k.prototype,"map",null),e([l()],k.prototype,"view",null),e([l({type:f})],k.prototype,"viewModel",void 0),k=e([a("esri.widgets.Feature")],k);export{k as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{getGraphicLayer as o}from"../../graphic/graphicOriginUtils.js";import{isGraphicsLayer as n}from"../../layers/support/layerUtils.js";import{zoomToFeature as a,zoomToClusteredFeatures as s,browseClusteredFeatures as c,removeSelectedFeature as u}from"./actions.js";const l="esri.widgets.Popup.PopupViewModel",d=()=>t.getLogger(l),g=t=>{const{event:r,view:l,viewModel:d}=t,{action:g}=r;if(!g)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:w,id:f}=g;if(!f)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(w)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(f===a.id)return p(d).catch(i);if(f===s.id)return v(d);if(f===c.id)return d.browseClusterEnabled=!d.browseClusterEnabled,d.featureMenuOpen=d.browseClusterEnabled,Promise.resolve();if(f===u.id){d.visible=!1;const{selectedFeature:t}=d;if(!t)return Promise.reject(new e(`trigger-action:${u.id}`,"selectedFeature is required",{selectedFeature:t}));const r=o(t);return n(r)?r.remove(t):l?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function w(e){const{selectedFeature:t,location:r,view:i}=e;return i?t??r??null:null}function f(e){if(!e)return!1;const t=o(e);return e.isAggregate&&"cluster"===t?.featureReduction?.type}async function m(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(i){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function p(t,i){const{location:o,selectedFeature:n,view:s,zoomFactor:c}=t;await(i?.viewModel?.updateGeometry());const u=i?.graphic,l=u?.geometry?u:w(t);if(!s||!l){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:l,view:s});throw d().error(t),t}const g=s.scale/c,f=u?.geometry??t.selectedFeature?.geometry??o,p=null!=f&&"point"===f.type&&await m(u??n,s);a.active=!0,a.disabled=!0;try{await t.zoomTo({target:{target:l,scale:p?g:void 0}})}catch(v){if(r(v))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:u??n});d().error(t)}finally{a.active=!1,a.disabled=!1,t.zoomToLocation=null,p&&(t.location=f)}}async function v(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:i});throw d().error(t),t}if(!r||!f(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw d().error(t),t}const[o,n]=await b(i,r);s.active=!0,s.disabled=!0;const{extent:a}=await o.queryExtent(n);a&&await t.zoomTo({target:a}),s.active=!1,s.disabled=!1}async function y(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[i,o]=await b(t,r),{extent:n}=await i.queryExtent(o);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function h(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[i,o]=await b(r,t);c.active=!0,c.disabled=!0;const{features:n}=await i.queryFeatures(o);c.active=!1,c.disabled=!1,c.value=!0;const a={features:[t].concat(n)};"feature"===e?.initialDisplayMode&&(a.featureMenuOpen=!0),e?.open(a)}async function b(e,t){const r=o(t),i=await e.whenLayerView(r),n=i.createQuery(),a=t.getObjectId();return n.aggregateIds=null!=a?[a]:[],[i,n]}function F(e){c.value=!1;const t=e.features.filter(e=>f(e));t.length&&(e.features=t)}export{h as browseAggregateFeatures,y as displayClusterExtent,w as getSelectedTarget,f as isClusterFeature,m as isZoomScreenSize,F as removeClusteredFeaturesForBrowsing,g as triggerAction,v as zoomToClusterExtent,p as zoomToLocation};
2
+ import e from"../../core/Error.js";import t from"../../core/Logger.js";import{isAbortError as r,throwIfNotAbortError as o}from"../../core/promiseUtils.js";import{getGraphicLayer as i}from"../../graphic/graphicOriginUtils.js";import{isGraphicsLayer as n}from"../../layers/support/layerUtils.js";import{browseClusteredFeatures as a,zoomToFeature as s,zoomToClusteredFeatures as c,removeSelectedFeature as u}from"./actions.js";const l="esri.widgets.Popup.PopupViewModel",d=()=>t.getLogger(l),g=t=>{const{event:r,view:l,viewModel:d}=t,{action:g}=r;if(!g)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));const{disabled:w,id:f}=g;if(!f)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(w)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(f===s.id)return m(d).catch(o);if(f===c.id)return v(d);if(f===a.id)return d.browseClusterEnabled=!d.browseClusterEnabled,d.featureMenuOpen=d.browseClusterEnabled,Promise.resolve();if(f===u.id){d.visible=!1;const{selectedFeature:t}=d;if(!t)return Promise.reject(new e(`trigger-action:${u.id}`,"selectedFeature is required",{selectedFeature:t}));const r=i(t);return n(r)?r.remove(t):l?.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function w(e){const{selectedFeature:t,location:r,view:o}=e;return o?t??r??null:null}function f(e){if(!e)return!1;const t=i(e);return e.isAggregate&&"cluster"===t?.featureReduction?.type}async function p(e,t){if("3d"!==t?.type||!e||"esri.Graphic"!==e.declaredClass)return!0;const r=t.getViewForGraphic(e);if(r&&"whenGraphicBounds"in r){let t=null;try{t=await r.whenGraphicBounds(e,{useViewElevation:!0})}catch(o){}return!t||!t.boundingBox||t.boundingBox[0]===t.boundingBox[3]&&t.boundingBox[1]===t.boundingBox[4]&&t.boundingBox[2]===t.boundingBox[5]}return!0}async function m(t,o){const{location:i,selectedFeature:n,view:a,zoomFactor:c}=t;await(o?.viewModel?.updateGeometry());const u=o?.graphic,l=u?.geometry?u:w(t);if(!a||!l){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:l,view:a});throw d().error(t),t}const g=a.scale/c,f=u?.geometry??t.selectedFeature?.geometry??i,m=null!=f&&"point"===f.type&&await p(u??n,a);s.active=!0,s.disabled=!0;try{await t.zoomTo({target:{target:l,scale:m?g:void 0}})}catch(v){if(r(v))return;const t=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:u??n});d().error(t)}finally{s.active=!1,s.disabled=!1,t.zoomToLocation=null,m&&(t.location=f)}}async function v(t){const{selectedFeature:r,view:o}=t;if("2d"!==o?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:o});throw d().error(t),t}if(!r||!f(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw d().error(t),t}const[i,n]=await b(o,r);c.active=!0,c.disabled=!0;const{extent:a}=await i.queryExtent(n);a&&await t.zoomTo({target:a}),c.active=!1,c.disabled=!1}async function y(e){const{view:t,selectedFeature:r}=e;if(!t||!r)return;const[o,i]=await b(t,r),{extent:n}=await o.queryExtent(i);e.selectedClusterBoundaryFeature.geometry=n,t.graphics.add(e.selectedClusterBoundaryFeature)}async function h(e){const{selectedFeature:t,view:r}=e;if(!r||!t)return;const[o,i]=await b(r,t);a.active=!0,a.disabled=!0;const{features:n}=await o.queryFeatures(i);a.active=!1,a.disabled=!1,a.value=!0;const s=[t].concat(n),c="feature"===e.initialDisplayMode,{open:u}=e;"function"!=typeof u?(e.features=s,e.featureMenuOpen=c,"boolean"==typeof u&&(e.open=!0)):u.call(e,{features:s,featureMenuOpen:c})}async function b(e,t){const r=i(t),o=await e.whenLayerView(r),n=o.createQuery(),a=t.getObjectId();return n.aggregateIds=null!=a?[a]:[],[o,n]}function F(e){a.value=!1;const t=e.features.filter(e=>f(e));t.length&&(e.features=t)}export{h as browseAggregateFeatures,y as displayClusterExtent,w as getSelectedTarget,f as isClusterFeature,p as isZoomScreenSize,F as removeClusteredFeaturesForBrowsing,g as triggerAction,v as zoomToClusterExtent,m as zoomToLocation};
@@ -1 +0,0 @@
1
- "use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[3500],{563(e,t,s){s.d(t,{QueueProcessor:()=>c,SharedConcurrency:()=>u});var i=s(97768),n=s(17676),r=s(9775),o=s(32587),l=s(76030),a=s(44794);class c{constructor(e){this._schedule=null,this._deferreds=new o.A,this._controllers=new o.A,this._processingItems=new o.A,this._pausedSignal=(0,a.v)(!1),this.process=e.process,this.concurrency=e.concurrency,this.sharedConcurrency=e.sharedConcurrency??f,this._queue=new r.A(e.peeker)}destroy(){this.clear(),this._schedule=(0,i.xt)(this._schedule)}get updating(){return this.running}get length(){return this._processingItems.size+this._queue.length}get running(){return!this._pausedSignal.value&&this._queue.length>0&&!this.full}get full(){return this._processingItems.size>=this.concurrency||this.sharedConcurrency.full}abort(e){const t=this._controllers.get(e);t?.abort()}clear(){this._queue.clear();const e=Array.from(this._controllers.values());this._controllers.clear(),e.forEach(e=>e.abort()),this.sharedConcurrency.current.value-=this._processingItems.size,this._processingItems.clear(),this._cancelNext()}forEach(e){this._deferreds.forEach((t,s)=>e(s))}_get(e){const t=this._deferreds.get(e);return t?.promise}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(e,t){const s=this._get(e);if(s)return s;const i=new AbortController,r=Promise.withResolvers(),o=t?(0,n.u7)(t,()=>i.abort()):null,l=(0,n.NY)(i.signal,()=>{const t=this._processingItems.get(e);t&&t.controller.abort(),a(),r.reject((0,n.NK)())}),a=()=>{l.remove(),o?.remove(),this._removeItem(e),this._queue.remove(e),this._scheduleNext()};return this._deferreds.set(e,r),this._controllers.set(e,i),r.promise.then(a,a),this._queue.push(e),this._scheduleNext(),r.promise}last(){return this._queue.last()}reset(){const e=Array.from(this._processingItems.values());this.sharedConcurrency.current.value-=this._processingItems.size,this._processingItems.clear();for(const t of e)this._queue.push(t.item),t.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const e=[];for(;this._queue.length;)e.push(this._queue.pop());return this.clear(),e}_removeItem(e){this._deferreds.delete(e),this._controllers.delete(e),this._processingItems.has(e)&&(this._processingItems.delete(e),this.sharedConcurrency.current.value-=1)}_scheduleNext(){this._pausedSignal.value||this._schedule||(this._schedule=(0,l._)(()=>{this._schedule=null,this._next()}))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency&&!this.sharedConcurrency.full;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).resolve(t))}_processError(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).reject(t))}_canProcessFulfillment(e){return!!this._deferreds.get(e.item)&&this._processingItems.get(e.item)===e}_process(e){if(null==e)return;let t;const s=new AbortController,i=new h(e,s);this._processingItems.set(e,i),this.sharedConcurrency.current.value+=1;try{t=this.process(e,s.signal)}catch(e){this._processError(i,e)}(0,n.$X)(t)?(i.promise=t,t.then(e=>this._processResult(i,e),e=>this._processError(i,e))):this._processResult(i,t)}}class h{constructor(e,t){this.item=e,this.controller=t,this.promise=null}}class u{constructor(e){this.limit=e,this.current=(0,a.v)(0)}get full(){return this.current.value>=this.limit}}const f=new u(1/0)},32587(e,t,s){s.d(t,{A:()=>r});var i=s(62788),n=s(95488);class r{constructor(e){this._observable=new n.I,this._notifyPending=!1,this._batchDepth=0,this._map=new Map(e)}get size(){return(0,i.gc)(this._observable),this._map.size}batch(e){try{this._batchDepth++,e()}finally{this._batchDepth--,this._notifyPending&&0===this._batchDepth&&(this._notifyPending=!1,this._notify())}}clear(){this._map.size>0&&(this._map.clear(),this._notify())}delete(e){const t=this._map.delete(e);return t&&this._notify(),t}entries(){return(0,i.gc)(this._observable),this._map.entries()}forEach(e,t){(0,i.gc)(this._observable),this._map.forEach((s,i)=>e.call(t,s,i,this),t)}get(e){return(0,i.gc)(this._observable),this._map.get(e)}has(e){return(0,i.gc)(this._observable),this._map.has(e)}keys(){return(0,i.gc)(this._observable),this._map.keys()}set(e,t){return this._map.set(e,t),this._notify(),this}transformValues(e,t=this._map.keys()){this.batch(()=>{for(const s of t){if(!this._map.has(s))continue;const t=this._map.get(s),i=e(t,s);i!==t&&this.set(s,i)}})}values(){return(0,i.gc)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.gc)(this._observable),this._map[Symbol.iterator]()}[Symbol.dispose](){this._observable.destroy()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}_notify(){this._batchDepth>0?this._notifyPending=!0:this._observable.notify()}}},44794(e,t,s){s.d(t,{v:()=>l});var i=s(4718),n=s(62788),r=s(95488);class o{constructor(e,t){this._observable=new r.I,this._value=e,this._equalityFunction=t}get value(){return(0,n.gc)(this._observable),this._value}set value(e){this._equalityFunction(e,this._value)||(this._value=e,this._observable.notify())}mutate(e){e(this._value),this._observable.notify()}}function l(e,t=i.gh){return new o(e,t)}},49859(e,t,s){s.d(t,{A:()=>E});var i=s(5482),n=s(11254),r=s(49186),o=s(25482),l=s(53966),a=s(17676),c=s(563),h=s(91429),u=s(56507),f=s(5443),m=s(86738),d=s(16930),p=s(7548),g=s(4366),x=s(37373);const y=new Map,_=new class{constructor(e=15e3,t=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=e,this._interval=Math.min(e,t)}decreaseRefCount(e,t){const s=e+"/"+t,i=this._cachedBlocks;if(i.has(s)){const e=i.get(s);return e.refCount--,e.refCount<=0&&(i.delete(s),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const s=e+"/"+t,i=this._cachedBlocks;if(i.has(s)){const e=i.get(s);return e.ts=Date.now(),e.refCount++,i.delete(s),i.set(s,e),e.block}return null}putBlock(e,t,s,i){const n=this._cachedBlocks,r=e+"/"+t;if(n.has(r)){const e=n.get(r);e.ts=Date.now(),e.refCount++}else n.set(r,{block:s,ts:Date.now(),refCount:1,controller:i});this._trim(),this._updateTimer()}deleteBlock(e,t){const s=this._cachedBlocks,i=e+"/"+t;s.has(i)&&s.delete(i)}updateMaxSize(e){this._size=e,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const e=this._cachedBlocks;this._timer=setInterval(()=>{const t=Array.from(e),s=Date.now();for(let i=0;i<t.length&&t[i][1].ts<=s-this._duration;i++)e.delete(t[i][0]);0===e.size&&this._clearTimer()},this._interval)}_trim(){const e=this._cachedBlocks;if(-1===this._size||this._size>=e.size)return;const t=Array.from(e);for(let s=0;s<t.length-this._size;s++)e.delete(t[s][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}};function I(e,t,s){const i=y.get(e);if(!i)return null==t?_.decreaseRefCount(e,s):0;if(null==t||null==i[t])return _.decreaseRefCount(e,s);const n=i[t]?.cache,r=n?.get(s);if(n&&r){if(r.refCount--,0===r.refCount){n.delete(s);for(let e=0;e<i.length;e++)i[e]?.cache.delete(s);r.controller&&r.controller.abort()}return r.refCount}return 0}function b(e,t,s){const i=y.get(e);if(!i)return null==t?_.getBlock(e,s):null;if(null==t||null==i[t]){for(let e=0;e<i.length;e++){const t=i[e]?.cache.get(s);if(t)return t.refCount++,t.block}return _.getBlock(e,s)}const n=i[t]?.cache.get(s);if(n)return n.refCount++,n.block;for(let e=0;e<i.length;e++){if(e===t||!i[e])continue;const n=i[e]?.cache,r=n?.get(s);if(n&&r)return r.refCount++,n.set(s,r),r.block}return null}function v(e,t,s,i,n=null){const r=y.get(e);if(!r)return void(null==t&&_.putBlock(e,s,i,n));if(null==t||null==r[t])return void _.putBlock(e,s,i,n);const o={refCount:1,block:i,isResolved:!1,isRejected:!1,controller:n};i.then(()=>o.isResolved=!0).catch(()=>o.isRejected=!0),r[t]?.cache.set(s,o)}function w(e,t,s){const i=y.get(e);i?null!=t&&null!=i[t]?i[t]?.cache.delete(s):_.deleteBlock(e,s):null==t&&_.deleteBlock(e,s)}var k=s(94778),R=s(20758),S=s(47520),C=s(34251),T=s(60694),B=s(10873),P=s(45617),M=s(91806),A=s(20223),z=s(87045);let W=0,E=class extends o.o{constructor(){super(...arguments),this._tileFetchQueue=new c.QueueProcessor({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"},this.rawBlockRegistryIds=[],this.refresh=(0,a.sg)(async e=>{await this._openPromise;const t=await this._refresh(e);return t.dataChanged&&function(e,t){const s=y.get(e);if(s){const e=t.map(e=>s[e]).filter(e=>null!=e);for(const t of e)t&&(Array.from(t.cache.values()).forEach(e=>{e.isResolved||e.isRejected||!e.controller||e.controller.abort()}),t.cache.clear())}}(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:z.A.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=(0,x.FT)(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),(0,p.qg)(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+W++}set url(e){this._set("url",(0,T.Jf)(e,l.A.getLogger(this)))}async open(e){return this._openPromise??=(0,x.Hh)().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,s,i={}){const n=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,s,n);if(!o)throw new r.A("imagery-tile:out-of-bounds","Level for fetch tile out of range");return i={noClip:!0,...i},this.fetchPixels(o,n.size[0],n.size[1],i)}async identify(e,t={}){e=(0,u.PZ)(m.A,e).clone().normalize();const{multidimensionalDefinition:s,timeExtent:i}=t,{rasterInfo:n}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:o}=n;let{transposedVariableName:l}=t;const a=null!=o&&r&&(null!=i||(0,g.DY)(s));a&&!l&&(l=null!=s&&s.length>0?s[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:l}),t=this._getRequestOptionsWithSliceId(t);const{spatialReference:c,extent:h}=n,{datumTransformation:d}=t;let y=(0,x._I)(e,c,d);if(!h.intersects(y))return{location:y,value:null};if(null!=n.transform){const e=n.transform.inverseTransform(y);if(!n.nativeExtent.intersects(e))return{location:e,value:null};y=e}let _=0;const I=null!=l&&null!=o&&n.hasMultidimensionalTranspose;if((0,p.qg)(this)){const e=this.primaryRasters.rasters[0];if(I)return e.identify(y,t);const{pixelSize:i}=n,r=3,o=i.x*r/2,l=i.y*r/2,a=new f.A({xmin:y.x-o,xmax:y.x+o,ymin:y.y-l,ymax:y.y+l,spatialReference:c}),h={interpolation:"nearest",multidimensionalDefinition:s,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(a,r,r,h),{pixelBlock:m}=await this.fetchPixels(a,r,r,h);if(null==u)return{location:y,value:null};const d=Math.floor(r*r*.5),p=!u.mask||u.mask[d]?u.pixels.map(e=>e[d]):null;let g;return null!=m&&(g=!m.mask||m.mask[d]?m.pixels.map(e=>e[d]):void 0),{location:y,value:p,processedValue:g,pyramidLevel:0}}if(!I)if(t.srcResolution)_=(0,x.t$)(t.srcResolution,n,this.ioConfig.sampling).pyramidLevel;else if(_=await this.computeBestPyramidLevelForLocation(e,t),null==_)return{location:y,value:null};const b=this.identifyPixelLocation(y,_,null,I);if(null===b)return{location:y,value:null};const{row:v,col:w,rowOffset:k,colOffset:R,blockWidth:S}=b,C=await this._fetchRawTile(_,v,w,t);if(!C?.pixels?.length)return{location:y,value:null};const T=k*S+R;return this._processIdentifyResult(C,{srcLocation:y,position:T,pyramidLevel:_,useTransposedTile:!!I,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,s,i={}){e=(0,x.Ps)(e),i=this._getRequestOptionsWithSliceId(i);const{_hasNoneOrGCSShiftTransform:n}=this;if(i.requestRawData&&n)return this._fetchPixels(e,t,s,i);const r=(0,x.FT)(e.spatialReference),o=(0,x.OM)(e);if(null==r||0===o||1===o&&this._isGlobalWrappableSource&&n)return this._fetchPixels(e,t,s,i);if(o>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,h=Math.round(r/(c-a)*t),u=h-Math.round((r/2-a)/(c-a)*t);let m=0;const d=[];for(let n=0;n<=o;n++){const p=new f.A({xmin:0===n?a:-r/2,xmax:n===o?c-r*n:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),g=0===n?h-u:n===o?t-m:h;m+=g,d.push(g);const x=i.disableWrapAround&&n>0?null:this._fetchPixels(p,g,s,i);l.push(x)}const p=(await Promise.all(l)).map(e=>e?.pixelBlock);let g=null;const y={width:t,height:s};return g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:d},i)).pixelBlock:(0,S.z7)(p,y,{blockWidths:d}),{extent:e,srcExtent:(0,x._l)(e,this.rasterInfo.spatialReference,i.datumTransformation),pixelBlock:g}}async fetchRawPixels(e,t,s,i={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const n=await this._fetchRawTiles(e,t,s,i),{nativeExtent:r,nativePixelSize:o,storageInfo:l}=this.rasterInfo,a=2**e,c=o.x*a,h=o.y*a,u=new f.A({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+s.width-1),ymin:r.ymax-h*(t.y+s.height-1),ymax:r.ymax-h*t.y,spatialReference:r.spatialReference});if(!n)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:m,mosaicSize:d}=n;if(1===m.length&&null!=m[0]&&m[0].width===s.width&&m[0].height===s.height)return{extent:u,srcExtent:u,pixelBlock:n.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,g=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%g};let y;return y=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:m,srcMosaicSize:d,destDimension:s,clipOffset:x,clipSize:s,coefs:null,sampleSpacing:null,interpolation:i.interpolation,alignmentInfo:null,blockWidths:null},i)).pixelBlock:(0,S.z7)(m,d,{clipOffset:x,clipSize:s}),{extent:u,srcExtent:u,pixelBlock:y}}fetchRawTile(e,t,s,i){throw new r.A("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return(0,x._l)(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?(0,R.D)(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,t,s=0){const{customFetchParameters:i}=this.ioConfig,{range:r,query:o,headers:l}=t;s=s??t.retryCount??this.ioConfig.retryCount;const a=r?{Range:`bytes=${r.from}-${r.to}`}:null;try{return await(0,n.A)(e,{...t,query:{...o,...i},headers:{...l,...a}})}catch(i){if(s>0)return s--,this.request(e,t,s);throw i}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:(0,g.NG)(e,t)}getTileExtentFromTileInfo(e,t,s,i){const n=i.lodAt(e);return n?this.getTileExtent({x:n.resolution,y:n.resolution},t,s,i.origin,i.spatialReference,i.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:s,pixelSize:i}=this.rasterInfo,{pyramidResolutions:n}=e;if(!e.tileInfo){const r=[],o=e.maximumPyramidLevel||0;let l=(i.x+i.y)/2,a=1/.0254*96*l;for(let e=0;e<=o&&(r.unshift(new M.A({level:o-e,resolution:l,scale:a})),e!==o);e++)if(n){const t=(n[e].x+n[e].y)/2;a*=t/l,l=t}else l*=2,a*=2;const c=new m.A({x:s.xmin,y:s.ymax,spatialReference:t});e.tileInfo=new z.A({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,s=512,i){const{width:n,height:r,nativeExtent:o,pixelSize:l,spatialReference:a}=e,c=new m.A({x:o.xmin,y:o.ymax,spatialReference:a});null==i&&(i=Math.max(0,Math.round(Math.log(Math.max(n,r))/Math.LN2-8)));const h=this.computeBlockBoundary(o,512,512,{x:o.xmin,y:o.ymax},[l],i);e.storageInfo=new A.A({blockWidth:t,blockHeight:s,pyramidBlockWidth:t,pyramidBlockHeight:s,origin:c,firstPyramidLevel:1,maximumPyramidLevel:i,blockBoundary:h})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,s,i,n,r=0,o=2){if(1===n.length&&r>0){n=[...n];let{x:e,y:t}=n[0];for(let s=0;s<r;s++)e*=o,t*=o,n.push({x:e,y:t})}const l=[],{x:a,y:c}=i;for(let i=0;i<n.length;i++){const{x:r,y:o}=n[i];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*o)/s/o),maxRow:Math.floor((c-e.ymin-.1*o)/s/o)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:s,pyramidScalingFactor:i}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=s&&s.length)return s[e-1];const n=i**e;return{x:t.x*n,y:t.y*n}}identifyPixelLocation(e,t,s,i){const{spatialReference:n,nativeExtent:r,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=o,h=i&&null!=c?c.tileSize[0]:o.blockWidth,u=i&&null!=c?c.tileSize[1]:o.blockHeight,f=(0,x._I)(e,n,s);if(!r.intersects(f))return null;if(t<0||t>l)return null;const m=this.getPyramidPixelSize(t),{x:d,y:p}=m,g=(a.y-f.y)/p/u,y=(f.x-a.x)/d/h,_=Math.min(u-1,Math.floor((g-Math.floor(g))*u)),I=Math.min(h-1,Math.floor((y-Math.floor(y))*h));return{pyramidLevel:t,row:Math.floor(g),col:Math.floor(y),rowOffset:_,colOffset:I,blockWidth:h,srcLocation:f}}getTileExtent(e,t,s,i,n,r){const[o,l]=r,a=i.x+s*o*e.x,c=a+o*e.x,h=i.y-t*l*e.y,u=h-l*e.y;return new f.A({xmin:a,xmax:c,ymin:u,ymax:h,spatialReference:n})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,s){const i=this.rasterInfo.storageInfo.blockBoundary[e];return!i||i.maxRow<t||i.maxCol<s||i.minRow>t||i.minCol>s}updateImageSpaceRasterInfo(e){const{pixelSize:t}=e,{width:s,height:i}=e,n=d.A.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new f.A({xmin:-.5,ymax:.5,xmax:s-.5,ymin:.5-i,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new m.A({x:1,y:1,spatialReference:n});const{extent:r,storageInfo:o}=e;if(o){o.origin=new m.A({x:r.xmin,y:r.ymax,spatialReference:n});const{pyramidResolutions:s,tileInfo:i}=o;if(s&&s.forEach(e=>{e.x/=t.x,e.y/=t.y}),i){i.origin=o.origin;const t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;i.lods.forEach((e,s)=>{e.resolution=t*2**s,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,s,i={}){let n=(0,x.OM)(e);if(n>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,s,i),{pyramidLevel:o,srcResolution:l,srcWidth:a,srcHeight:c,ul:h}=r;let{srcExtent:u}=r;if(0===a||0===c)return{extent:e,srcExtent:u,pixelBlock:null};const{rasterInfo:f}=this,d=f.transform,p="gcs-shift"===d?.type,g=null!=(0,x.FT)(e.spatialReference);!p&&g||(n=(0,x.OM)(u,p));const y=await this._fetchRawTiles(o,h,{width:a,height:c,wrapCount:n},i);if(!y)return{extent:e,srcExtent:u,pixelBlock:null};u=y.extent;const _=f.storageInfo,I=o>0?_.pyramidBlockWidth:_.blockWidth,b=o>0?_.pyramidBlockHeight:_.blockHeight;let{x:v,y:w}=f.pixelSize;if(o>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=_;if(null!=e&&e[o-1])({x:v,y:w}=e[o-1]);else{const e=t**o;v*=e,w*=e}}const k=f.spatialReference,R=new m.A({x:v,y:w,spatialReference:k}),T=I===a&&b===c&&h.x%I===0&&h.y%b===0,B=new m.A({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/s,spatialReference:e.spatialReference}),P=!e.spatialReference.equals(k),M=k.isGeographic?1e-9:1e-4,{datumTransformation:A}=i;if(!P&&T&&1===y.pixelBlocks.length&&I===t&&b===s&&function(e,t,s){return Math.abs(e.x-t.x)<s&&Math.abs(e.y-t.y)<s}(l,B,M))return{extent:e,srcExtent:u,srcTilePixelSize:R,pixelBlock:y.pixelBlocks[0]};const z=g&&null!=(0,x.FT)(u.spatialReference)&&this._hasNoneOrGCSShiftTransform,W=i.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");W&&!this.rasterJobHandler&&await(0,x.Hh)();const E=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:u,pixelSize:B.toJSON(),datumTransformation:A,rasterTransform:d,hasWrapAround:n>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:W},i):(0,x.l0)({projectedExtent:e,srcBufferExtent:u,pixelSize:B,datumTransformation:A,rasterTransform:d,hasWrapAround:n>0||z,isAdaptive:!1,includeGCSGrid:W});let N;const D=!i.requestRawData,H={rows:E.spacing[0],cols:E.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,u.xmin):void 0,{pixelBlocks:L,mosaicSize:O,isPartiallyFilled:F}=y;let G=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:L,srcMosaicSize:O,destDimension:D?{width:t,height:s}:null,coefs:D?E.coefficients:null,sampleSpacing:D?H:null,projectDirections:W,gcsGrid:W?E.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:i.interpolation,alignmentInfo:q,blockWidths:null},i);({pixelBlock:N,localNorthDirections:G}=e)}else{const e=(0,S.z7)(L,O,{alignmentInfo:q});N=D?(0,S.$i)(e,{width:t,height:s},E.coefficients,H,i.interpolation):e,W&&E.gcsGrid&&(G=(0,S.QF)({width:t,height:s},E.gcsGrid),N=(0,C.Y2)(N,this.rasterInfo.dataType,G))}return i.requestRawData||W?{extent:e,srcExtent:u,srcTilePixelSize:R,pixelBlock:N,transformGrid:E,localNorthDirections:G,isPartiallyFilled:F}:{extent:e,srcExtent:e,srcTilePixelSize:R,pixelBlock:N}}async _fetchRawTiles(e,t,s,i){const{origin:n,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:h,height:u,wrapCount:m}=s;const d=this._getRasterTileAlignmentInfo(e,0);i.buffer&&(a-=i.buffer.cols,c-=i.buffer.rows,h+=2*i.buffer.cols,u+=2*i.buffer.rows);let p=0,g=0,x=0;m&&null!=d&&(({worldColumnCountFromOrigin:g,originColumnOffset:x,rightPadding:p}=d),g*d.blockWidth-p>=a+h&&(p=0));const y=Math.floor(a/o),_=Math.floor(c/l),I=Math.floor((a+h+p-1)/o),b=Math.floor((c+u+p-1)/l),v=r[e];if(!v)return null;const{minRow:w,minCol:k,maxCol:R,maxRow:S}=v;if(0===m&&(b<w||I<k||_>S||y>R))return null;const C=new Array;let T=!1;const B=null==this.ioConfig.allowPartialFill?i.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=_;t<=b;t++)for(let s=y;s<=I;s++){let n=s;if(!i.disableWrapAround&&m&&null!=d&&g<=s&&(n=s-g-x),t>=w&&n>=k&&S>=t&&R>=n){const s=this._fetchRawTile(e,t,n,i);B?C.push(new Promise(e=>{s.then(t=>e(t)).catch(()=>{T=!0,e(null)})})):C.push(s)}else C.push(Promise.resolve(null))}if(0===C.length)return null;const P=await Promise.all(C),M={height:(b-_+1)*l,width:(I-y+1)*o},{spatialReference:A}=this.rasterInfo,z=this.getPyramidPixelSize(e),{x:W,y:E}=z;return{extent:new f.A({xmin:n.x+y*o*W,xmax:n.x+(I+1)*o*W,ymin:n.y-(b+1)*l*E,ymax:n.y-_*l*E,spatialReference:A}),pixelBlocks:P,mosaicSize:M,isPartiallyFilled:T}}_fetchRawTile(e,t,s,i){const{storageInfo:n}=this.rasterInfo,r=null!=n.transposeInfo&&!!i.transposedVariableName;if(!r){const i=n.blockBoundary[e];if(!i)return Promise.resolve(null);const{minRow:r,minCol:o,maxCol:l,maxRow:a}=i;if(t<r||s<o||t>a||s>l)return Promise.resolve(null)}const o=r?i.transposeVariableName:i.sliceId,l=n.isBsqTile?i.bandIds:null,c=function(e,t,s){const i=[];return null!=t&&i.push(`sliceId=${t}`),null!=s&&i.push(`bandIds=${s.join(",")}`),i.length?`${e}?${i.join("&")}`:e}(this.rasterId,o,l),h=`${e}/${t}/${s}`;let u=b(c,i.registryId,h);if(null==u){const r=new AbortController,o=i.bandIds?.slice();if(o?.length&&n.isBsqTile){const n=new Set(o),l=[],a=Array.from(n);for(const n of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:s,options:{...i,bandIds:[n]}},{signal:r.signal}));u=Promise.all(l).then(e=>{if(e.some(e=>null==e))return null;if(a.length!==o.length){const t=[];for(const s of o){let i=e[a.indexOf(s)];t.includes(i)&&(i=i.clone()),t.push(i)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:r.signal,transferPixelsToWorker:!0}):(0,S.Wy)(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:s,options:i},{signal:r.signal});v(c,i.registryId,h,u,r),u.catch(()=>w(c,i.registryId,h))}return i.signal&&(0,a.u7)(i,()=>{I(c,i.registryId,h)}),u}_computeMagDirValues(e){const{bandCount:t,dataType:s}=this.rasterInfo;if((2!==t||"vector-magdir"!==s)&&"vector-uv"!==s||2!==e?.length||!e[0]?.length)return null;const i=e[0].length;if("vector-magdir"===s){const t=e[1].map(e=>(e+360)%360);return[e[0],t]}const[n,r]=e,o=[],l=[];for(let e=0;e<i;e++){const[t,s]=(0,C.Lu)([n[e],r[e]]);o.push(t),l.push(s)}return[o,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=(0,x.DO)(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,s,i={}){const n={datumTransformation:i.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};i.srcResolution&&(n.srcResolution=i.srcResolution,this._updateSourceDataInfo(e,n));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:l,pyramidLevel:a}=n,c=o/t,h=l/s,u=a<r&&c*h>=16,f=a===r&&this._requireTooManySrcTiles(o,l,t,s);if(u||f||0===o||0===l){const o=new m.A({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/s,spatialReference:e.spatialReference});let l=(0,x.Wo)(o,this.rasterInfo.spatialReference,e,n.datumTransformation);const f=!l||i.srcResolution&&l.x+l.y<i.srcResolution.x+i.srcResolution.y;if(u&&i.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,h))/Math.LN2)-1;if(r-a+3>=e){const t=2**e;l={x:i.srcResolution.x*t,y:i.srcResolution.y*t}}}l&&(n.srcResolution=l,this._updateSourceDataInfo(e,n))}return this._requireTooManySrcTiles(n.srcWidth,n.srcHeight,t,s)&&(n.srcWidth=0,n.srcHeight=0),n}_requireTooManySrcTiles(e,t,s,i){const{tileInfo:n}=this.rasterInfo.storageInfo,r=e/s,o=t/i;return Math.ceil(e/n.size[0])*Math.ceil(t/n.size[1])>=256*Math.max(1,(s+i)/1024)||r>8||o>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:s}=this,i=s.spatialReference,{srcResolution:n,datumTransformation:r}=t,{pyramidLevel:o,pyramidResolution:l,excessiveReading:a}=(0,x.t$)(n,s,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||(0,x._l)(e,i,r);if(null==c)return;const h=s.transform;h&&(c=h.inverseTransform(c)),t.srcExtent=c;const{origin:u}=s.storageInfo,{width:f,height:m,ul:d}=(0,p.$g)(c,u,l,o);t.pyramidLevel=o,t.pyramidResolution=l,t.srcWidth=f,t.srcHeight=m,t.ul=d}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:s,position:i,pyramidLevel:n,useTransposedTile:r}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[i])return{location:s,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!r){const t=e.pixels.map(e=>e[i]),r={location:s,value:t,pyramidLevel:n},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(r.magdirValue=o.map(e=>e[0])),r}let a=e.pixels.map(e=>e.slice(i*o,i*o+o)),c=this._computeMagDirValues(a);const{requestSomeSlices:h,identifyOptions:u}=t;let f=(0,g.QW)(l,u.transposedVariableName);if(h){const e=(0,g.xx)(f,u.multidimensionalDefinition,u.timeExtent);a=a.map(t=>e.map(e=>t[e])),c=c?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}const m=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let p;return null!=m&&((0,k.Sp)(d,m),p=d.mask),{location:s,value:null,dataSeries:f.map((e,t)=>{const s={value:0===p?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new P.A({...e,isSlice:!0}))};return c?.length&&(s.magdirValue=[c[0][t],c[1][t]]),s}),pyramidLevel:n}}};(0,i.Cg)([(0,h.MZ)()],E.prototype,"_rasterTileAlignmentInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"_tileFetchQueue",void 0),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"_isGlobalWrappableSource",null),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"_hasNoneOrGCSShiftTransform",null),(0,i.Cg)([(0,h.MZ)()],E.prototype,"_openPromise",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rasterJobHandler",null),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"rasterId",null),(0,i.Cg)([(0,h.MZ)(B.OZ)],E.prototype,"url",null),(0,i.Cg)([(0,h.MZ)({type:String,json:{write:!0}})],E.prototype,"datasetName",void 0),(0,i.Cg)([(0,h.MZ)({type:String,json:{write:!0}})],E.prototype,"datasetFormat",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"hasUniqueSourceStorageInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rasterInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"ioConfig",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"sourceJSON",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rawBlockRegistryIds",void 0),E=(0,i.Cg)([(0,h.$K)("esri.layers.raster.datasets.BaseRaster")],E)},330(e,t,s){function i(e,t){if(!e||!t)return[];let s=t;t.includes("/")?(s=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const n=[];if(t){const r=i(e,s);for(let e=0;e<r.length;e++)i(r[e],t).forEach(e=>n.push(e));return n}const r=e.getElementsByTagNameNS("*",s);if(!r||0===r.length)return[];for(let e=0;e<r.length;e++)n.push(r[e]||r.item(e));return n}function n(e,t){if(!e||!t)return null;let s=t;t.includes("/")?(s=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const r=i(e,s);return r.length>0?t?n(r[0],t):r[0]:null}function r(e,t=null){const s=t?n(e,t):e;let i;return s?(i=s.textContent||s.nodeValue,i?i.trim():null):null}function o(e,t){const s=i(e,t),n=[];let r;for(let e=0;e<s.length;e++)r=s[e].textContent||s[e].nodeValue,r&&(r=r.trim(),""!==r&&n.push(r));return n}function l(e,t=null){const s=r(e,t);return s?.split(" ").map(e=>Number(e))??[]}function a(e,t){return o(e,t).map(e=>Number(e))}function c(e,t){const s=r(e,t);return Number(s)}function h(e,t){const s=e?.nodeName?.toLowerCase(),i=t.toLowerCase();return s.slice(s.lastIndexOf(":")+1)===i}function u(e){return e.nodeName.slice(e.nodeName.lastIndexOf(":")+1)}s.d(t,{Dy:()=>o,IC:()=>i,Ui:()=>a,V6:()=>n,g7:()=>h,mX:()=>r,pN:()=>l,v7:()=>c,vv:()=>u})}}]);