// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../../../chunks/tslib.es6 ../../../core/Accessor ../../../core/arrayUtils ../../../core/accessorSupport/decorators/property ../../../core/accessorSupport/decorators/cast ../../../core/has ../../../core/accessorSupport/decorators/subclass ../../../popup/FieldInfo ../../../popup/content/support/ChartMediaInfoValueSeries ../support/featureUtils ../support/relatedFeatureUtils".split(" "),function(k,f,A,m,B,F,C,D,E,l,y){const z={chartAnimation:!0};f=class extends f{constructor(a){super(a);this.abilities= {...z};this.activeMediaInfoIndex=0;this.expressionAttributes=this.formattedAttributes=this.fieldInfoMap=this.description=this.attributes=null;this.isAggregate=!1;this.title=this.relatedInfos=this.popupTemplate=this.mediaInfos=this.layer=null}castAbilities(a){return{...z,...a}}get activeMediaInfo(){return this.formattedMediaInfos[this.activeMediaInfoIndex]||null}get formattedMediaInfos(){return this._formatMediaInfos()||[]}get formattedMediaInfoCount(){return this.formattedMediaInfos.length}setActiveMedia(a){this._setContentElementMedia(a)}next(){this._pageContentElementMedia(1)}previous(){this._pageContentElementMedia(-1)}_setContentElementMedia(a){const {formattedMediaInfoCount:c}= this;this.activeMediaInfoIndex=(a+c)%c}_pageContentElementMedia(a){const {activeMediaInfoIndex:c}=this;this._setContentElementMedia(c+a)}_formatMediaInfos(){const {mediaInfos:a,layer:c}=this,d=this.attributes??{},g=this.formattedAttributes??{},n=this.expressionAttributes??{},e=this.fieldInfoMap??new Map;return a?.map(b=>{b=b?.clone();if(!b)return null;b.title=l.substituteFieldsInLinksAndAttributes({attributes:d,fieldInfoMap:e,globalAttributes:g,expressionAttributes:n,layer:c,text:b.title});b.caption= l.substituteFieldsInLinksAndAttributes({attributes:d,fieldInfoMap:e,globalAttributes:g,expressionAttributes:n,layer:c,text:b.caption});b.altText=l.substituteFieldsInLinksAndAttributes({attributes:d,fieldInfoMap:e,globalAttributes:g,expressionAttributes:n,layer:c,text:b.altText});if("image"===b.type){if(!b.value)return;this._setImageValue({value:b.value,formattedAttributes:g,layer:c});return b.value.sourceURL?b:void 0}if("pie-chart"===b.type||"line-chart"===b.type||"column-chart"===b.type||"bar-chart"=== b.type){if(!b.value)return;this._setChartValue({value:b.value,chartType:b.type,attributes:d,formattedAttributes:g,layer:c,expressionAttributes:n});return b}return null}).filter(A.isSome)??[]}_setImageValue(a){const c=this.fieldInfoMap??new Map,{value:d,formattedAttributes:g,layer:n}=a,{linkURL:e,sourceURL:b}=d;b&&(a=l.fixTokens(b,n),d.sourceURL=l.substituteAttributes({formattedAttributes:g,template:a,fieldInfoMap:c}));e&&(a=l.fixTokens(e,n),d.linkURL=l.substituteAttributes({formattedAttributes:g, template:a,fieldInfoMap:c}))}_setChartValue(a){const {value:c,attributes:d,formattedAttributes:g,chartType:n,layer:e,expressionAttributes:b}=a,{popupTemplate:u,relatedInfos:v}=this,{fields:r,normalizeField:x}=c;c.fields=l.getFixedFieldNames(r,e);x&&(c.normalizeField=l.getFixedFieldName(x,e));if(r.some(h=>!!(null!=g[h]||l.isRelatedField(h)&&v?.size))){var p=u?.fieldInfos??[];r.forEach((h,q)=>{q=c.colors?.[q];l.isRelatedField(h)?c.series=[...c.series,...this._getRelatedChartInfos({fieldInfos:p,fieldName:h, formattedAttributes:g,chartType:n,value:c,color:q})]:(h=this._getChartOption({value:c,attributes:d,chartType:n,formattedAttributes:g,expressionAttributes:b,fieldName:h,fieldInfos:p,color:q}),c.series.push(h))})}}_getRelatedChartInfos(a){const {fieldInfos:c,fieldName:d,formattedAttributes:g,chartType:n,value:e,color:b}=a,u=[],v=y.getRelatedFieldInfo(d);a=v&&this.relatedInfos?.get(v.layerId.toString());if(!a)return u;const {relatedFeatures:r,relation:x}=a;if(!x||!r)return u;({cardinality:a}=x);r.forEach(p=> {const {attributes:h}=p;h&&Object.keys(h).forEach(q=>{q===v.fieldName&&u.push(this._getChartOption({value:e,attributes:h,formattedAttributes:g,fieldName:d,chartType:n,relatedFieldName:q,hasMultipleRelatedFeatures:1