/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import{__decorate as e}from"tslib";import{Clonable as r}from"../../core/Clonable.js";import{JSONSupportMixin as t}from"../../core/JSONSupport.js";import{clone as o}from"../../core/lang.js";import{toPt as i}from"../../core/screenUtils.js";import{property as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{ensureNumber as l}from"../../core/accessorSupport/ensureType.js";import p from"./AggregateField.js";import{createDefaultRenderer as u}from"./featureLayerUtils.js";import{maxScaleProperty as a,popupEnabledProperty as d,popupTemplateProperty as c,rendererProperty as f,labelingInfoProperty as m,labelsVisibleProperty as g,layerProperty as y,fieldConfigurationsProperty as h,fieldsProperty as b,fieldsIndexProperty as S}from"./featureReductionProperties.js";import j from"../../renderers/SimpleRenderer.js";import{read as w}from"../../renderers/support/jsonUtils.js";import{symbolTypesCluster as v}from"../../symbols/support/typeUtils.js";import{reader as x}from"../../core/accessorSupport/decorators/reader.js";import{writer as I}from"../../core/accessorSupport/decorators/writer.js";function C(e){return"simple"===e.type&&!e.visualVariables?.length}let z=class extends(t(r)){constructor(e){super(e),this.type="cluster",this.maxScale=0,this.popupEnabled=!0,this.popupTemplate=null,this.renderer=null,this.symbol=null,this.labelingInfo=null,this.labelsVisible=!0,this.fields=[]}get clusterRadius(){return this._get("clusterRadius")??i("80px")}set clusterRadius(e){this._set("clusterRadius",e)}get clusterMinSize(){return this._get("clusterMinSize")??i("12px")}set clusterMinSize(e){this._set("clusterMinSize",e)}get clusterMaxSize(){return this._get("clusterMaxSize")??i("50px")}set clusterMaxSize(e){this._set("clusterMaxSize",e)}readRenderer(e,r,t){const o=r.drawingInfo?.renderer;return o?.authoringInfo?.isAutoGenerated?null:o?C(o)?null:w(o,r,t)??void 0:u(r,t)}readSymbol(e,r,t){const o=r.drawingInfo?.renderer;if(o?.authoringInfo?.isAutoGenerated)return null;if(o&&C(o)){const e=w(o,r,t);return e?.symbol}return null}writeSymbol(e,r,t,o){const i=this.renderer?.authoringInfo?.isAutoGenerated;if(!this.renderer||i){const t=new j({symbol:e});r.drawingInfo={renderer:t.write({},o)}}}readFields(e,r,t){return e.filter(e=>!e.isAutoGenerated).map(e=>p.fromJSON(e))}clone(){const e=super.clone();return this._isOverridden("fieldConfigurations")&&(e.fieldConfigurations=o(this.fieldConfigurations)),e}getField(e){return this.fieldsIndex.get(e)}getFieldAlias(e){const r=this.getField(e);if(r)return this.getFieldConfiguration(r.name)?.alias||r.alias}getFieldConfiguration(e){return e=e.toLowerCase(),this.fieldConfigurations?.find(r=>r.name.toLowerCase()===e)}};e([s({type:["cluster"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0}}})],z.prototype,"type",void 0),e([s({cast:e=>"auto"===e?e:l(i(e)),json:{write:{ignoreOrigin:!0}}})],z.prototype,"clusterRadius",null),e([s({type:Number,cast:i,json:{write:{ignoreOrigin:!0}}})],z.prototype,"clusterMinSize",null),e([s({type:Number,cast:i,json:{write:{ignoreOrigin:!0}}})],z.prototype,"clusterMaxSize",null),e([s(a())],z.prototype,"maxScale",void 0),e([s(d())],z.prototype,"popupEnabled",void 0),e([s(c())],z.prototype,"popupTemplate",void 0),e([s(f())],z.prototype,"renderer",void 0),e([x("renderer",["drawingInfo.renderer"])],z.prototype,"readRenderer",null),e([s({types:v,json:{write:{ignoreOrigin:!0}}})],z.prototype,"symbol",void 0),e([x("symbol",["drawingInfo.renderer"])],z.prototype,"readSymbol",null),e([I("symbol")],z.prototype,"writeSymbol",null),e([s(m())],z.prototype,"labelingInfo",void 0),e([s(g())],z.prototype,"labelsVisible",void 0),e([s(y())],z.prototype,"layer",void 0),e([s(h())],z.prototype,"fieldConfigurations",void 0),e([s(b())],z.prototype,"fields",void 0),e([x("fields")],z.prototype,"readFields",null),e([s(S())],z.prototype,"fieldsIndex",void 0),z=e([n("esri.layers.support.FeatureReductionCluster")],z);export{z as default};
