/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../chunks/_rollupPluginBabelHelpers","../../../PopupTemplate","../../../intl/messages","../../../intl/substitute","../../../layers/support/fieldUtils","../../../popup/ExpressionInfo","../../../popup/FieldInfo","../../../popup/support/FieldInfoFormat","../../support/clusterUtils","../../../views/2d/layers/support/clusterUtils"],(function(e,t,s,i,l,n,r,u,a,o,p){"use strict";function c(e){const{fieldName:t,label:s,type:i}=e,l=n.numericTypes.includes(i),r=new u({fieldName:t,label:s,visible:!0,format:l?{places:"integer"===i||"small-integer"===i?0:2,digitSeparator:!0}:null});return"date"===i&&(r.format=new a({dateFormat:"short-date-short-time"})),r}function d(e,t){const s=t.getField(e);return s&&(s.alias||s.name)}function f(e,t,s){const{attributeInfo:i,statisticType:n}=t,{field:r,normalizationField:u}=i;let a,o="";if("avg"===n?a=u?s.clusters.avgNormFieldLabel:s.clusters.avgFieldLabel:"type"===n&&(a=s.clusters.predominantFieldLabel),a){const t=i.valueExpression?i.valueExpressionTitle:d(r,e),s=u&&d(u,e);o=l.substitute(a,{fieldLabel:t||"",normFieldLabel:s||""})}return o}function m(e,t,s,i){const{attributeInfo:n,statisticType:r}=t,{field:u,normalizationField:a}=n;let o,p="";if("avg"===r?o=a?i.clusters.avgNormFieldSummary:i.clusters.avgFieldSummary:"type"===r&&(o=i.clusters.predominantFieldSummary),o){const t=n.valueExpression?n.valueExpressionTitle:d(u,e),i=a&&d(a,e);p=l.substitute(o,{fieldLabel:t||"",normFieldLabel:i||"",fieldValue:"{"+s+"}"})}return p}function b(e,t){return y.apply(this,arguments)}function y(){return(y=t._asyncToGenerator((function*(e,t){if(!p.isClusterCompatibleRenderer(t))return null;const n=o.getStatisticInfos(e,t),u=yield i.fetchMessageBundle("esri/smartMapping/t9n/smartMapping"),a=u.clusters.predominantNoneValue,d="unique-value"===t.type?t.uniqueValueInfos:[],b=[],y=[],g=[];b.push(l.substitute(u.clusters.countSummary,{count:`{${o.clusterCountField}}`})),y.push(c({fieldName:o.clusterCountField,label:u.clusters.numFeatures,type:"integer"}));for(const s of n){const{statisticType:t,attributeInfo:i}=s,l=o.getClusterField(i,t),n=f(e,s,u);if("avg"===t)b.push(m(e,s,l,u)),y.push(c({fieldName:l,label:n,type:"double"}));else if("type"===t){const t=`expression/${l}`;b.push(m(e,s,t,u)),g.push(new r({name:l,title:n,returnType:"string",expression:o.getPredominantTypeExpression(d,l,a)})),y.push(c({fieldName:t}))}}return new s({fieldInfos:y,expressionInfos:g,content:b.join("<br/><br/>"),title:u.clusters.clusterPopupTitle})}))).apply(this,arguments)}e.createPopupTemplate=b,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
