/* COPYRIGHT Esri - https://js.arcgis.com/5.1.2/LICENSE.txt */
import e from"../../PopupTemplate.js";import{clone as r}from"../../core/lang.js";import{setDeepValue as i}from"../../core/object.js";import t from"./AggregateField.js";import n from"./AggregateFieldsIndex.js";import{labelsVisible as o,popupEnabled as s}from"./commonProperties.js";import l from"./FieldConfiguration.js";import{fieldConfigurationsFromPopupTemplate as f,popupTemplateWithFieldConfigurations as u}from"./fieldConfigUtils.js";import a from"./LabelClass.js";import{supportsFieldConfiguration as g}from"./layerUtils.js";import{rendererTypes as p}from"../../renderers/support/typeUtils.js";function m(){return{type:[l],clonable:!1,json:{name:"fieldConfigurations",write:{overridePolicy(e){return{enabled:g(this.layer),ignoreOrigin:!0}}}},set:function(e){if(this._override("fieldConfigurations",e),!this.layer?.loaded)return;const r=u(this,e);r&&this._set("popupTemplate",r)},get:function(){return this._isOverridden("fieldConfigurations")?this._get("fieldConfigurations"):this.layer?.loaded?f(this)||null:void 0}}}function d(){return{type:[t],value:[],json:{write:{ignoreOrigin:!0,writer(e,r,t){const n=e.filter(e=>"avg_angle"!==e.statisticType).map(e=>e.toJSON());i(t,n,r)}}},set:function(e){_(this._get("fields"),null),_(e,this.layer),this._set("fields",e)}}}function c(){return{readOnly:!0,get:function(){return new n(this.fields)}}}function j(){return{type:[a],json:{read:{source:"drawingInfo.labelingInfo"},write:{target:"drawingInfo.labelingInfo",ignoreOrigin:!0}}}}function y(){return v(r(o))}function h(){return{clonable:!1,set:function(e){_(this.fields,e),this._set("layer",e)}}}function w(){return{type:Number,json:{default:0,name:"visibilityInfo.maxScale",write:{ignoreOrigin:!0}}}}function O(){return v(r(s))}function b(){return{type:e,json:{name:"popupInfo",write:{ignoreOrigin:!0,writer(e,r,i,t){e&&(r[i]=e.toJSON({...t,writeFieldFormat:g(this.layer)}))}}}}}function I(){return{types:p,json:{write:{target:"drawingInfo.renderer",ignoreOrigin:!0}}}}function _(e,r){e?.forEach(e=>{e.layer=r})}function v(e){let r=e.json;r||(r=e.json={});let i=r.write;return null!=i&&"object"==typeof i||(i=r.write={}),i.ignoreOrigin=!0,e}export{m as fieldConfigurationsProperty,c as fieldsIndexProperty,d as fieldsProperty,j as labelingInfoProperty,y as labelsVisibleProperty,h as layerProperty,w as maxScaleProperty,O as popupEnabledProperty,b as popupTemplateProperty,I as rendererProperty};
