/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{__decorate as e}from"tslib";import r from"../../PopupTemplate.js";import{JSONSupport as t}from"../../core/JSONSupport.js";import{clone as o}from"../../core/lang.js";import{setDeepValue as s}from"../../core/object.js";import{toPt as i}from"../../core/screenUtils.js";import{property as l,subclass as p}from"../../core/accessorSupport/decorators.js";import{ensureNumber as n}from"../../core/accessorSupport/ensureType.js";import a from"./AggregateField.js";import{popupEnabled as u,labelsVisible as d}from"./commonProperties.js";import{createDefaultRenderer as m}from"./featureLayerUtils.js";import c from"./LabelClass.js";import f from"../../renderers/SimpleRenderer.js";import{read as y}from"../../renderers/support/jsonUtils.js";import{rendererTypes as b}from"../../renderers/support/typeUtils.js";import{symbolTypesCluster as g}from"../../symbols/support/typeUtils.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";import{writer as S}from"../../core/accessorSupport/decorators/writer.js";var j;function w(e){return"simple"===e.type&&!e.visualVariables?.length}let I=j=class extends t{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?w(o)?null:y(o,r,t)??void 0:m(r,t)}readSymbol(e,r,t){const o=r.drawingInfo?.renderer;if(o?.authoringInfo?.isAutoGenerated)return null;if(o&&w(o)){const e=y(o,r,t);return e?.symbol}return null}writeSymbol(e,r,t,o){const s=this.renderer?.authoringInfo?.isAutoGenerated;if(!this.renderer||s){const t=new f({symbol:e});r.drawingInfo={renderer:t.write({},o)}}}writeFields(e,r,t){const o=e.filter(e=>"avg_angle"!==e.statisticType).map(e=>e.toJSON());s(t,o,r)}readFields(e,r,t){return e.filter(e=>!e.isAutoGenerated).map(e=>a.fromJSON(e))}clone(){return new j({clusterRadius:this.clusterRadius,clusterMinSize:this.clusterMinSize,clusterMaxSize:this.clusterMaxSize,labelingInfo:o(this.labelingInfo),labelsVisible:this.labelsVisible,fields:o(this.fields),maxScale:this.maxScale,renderer:o(this.renderer),symbol:o(this.symbol),popupEnabled:this.popupEnabled,popupTemplate:o(this.popupTemplate)})}};e([l({type:["cluster"],readOnly:!0,json:{write:!0}})],I.prototype,"type",void 0),e([l({cast:e=>"auto"===e?e:n(i(e)),json:{write:!0}})],I.prototype,"clusterRadius",null),e([l({type:Number,cast:i,json:{write:!0}})],I.prototype,"clusterMinSize",null),e([l({type:Number,cast:i,json:{write:!0}})],I.prototype,"clusterMaxSize",null),e([l({type:Number,json:{default:0,name:"visibilityInfo.maxScale"}})],I.prototype,"maxScale",void 0),e([l(u)],I.prototype,"popupEnabled",void 0),e([l({type:r,json:{read:{source:"popupInfo"},write:{target:"popupInfo"}}})],I.prototype,"popupTemplate",void 0),e([l({types:b,json:{write:{target:"drawingInfo.renderer"}}})],I.prototype,"renderer",void 0),e([h("renderer",["drawingInfo.renderer"])],I.prototype,"readRenderer",null),e([l({types:g})],I.prototype,"symbol",void 0),e([h("symbol",["drawingInfo.renderer"])],I.prototype,"readSymbol",null),e([S("symbol")],I.prototype,"writeSymbol",null),e([l({type:[c],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo"}}})],I.prototype,"labelingInfo",void 0),e([l(d)],I.prototype,"labelsVisible",void 0),e([l({type:[a],json:{write:!0}})],I.prototype,"fields",void 0),e([S("fields")],I.prototype,"writeFields",null),e([h("fields")],I.prototype,"readFields",null),I=j=e([p("esri.layers.support.FeatureReductionCluster")],I);export{I as default};
