/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import e from"../../PopupTemplate.js";import{clone as i}from"../../core/lang.js";import{setDeepValue as r}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 f from"./FieldConfiguration.js";import{fieldConfigurationsFromPopupTemplate as l,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 d(){return{type:[f],json:{name:"fieldConfigurations",write:{overridePolicy(e,i){return{enabled:g(this.layer),ignoreOrigin:1!==this.originIdOf(i)}}}},set:function(e){if(this._override("fieldConfigurations",e),!this.layer?.loaded)return;const i=u(this,e);i&&this._set("popupTemplate",i)},get:function(){return this._isOverridden("fieldConfigurations")?this._get("fieldConfigurations"):this.layer?.loaded?l(this)||null:void 0}}}function m(){return{type:[t],value:[],json:{write:{ignoreOrigin:!0,writer(e,i,t){const n=e.filter(e=>"avg_angle"!==e.statisticType).map(e=>e.toJSON());r(t,n,i)}}},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(i(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(i(s))}function b(){return{type:e,json:{name:"popupInfo",write:{ignoreOrigin:!0,writer(e,i,r,t){e&&(i[r]=e.toJSON({...t,writeFieldFormat:g(this.layer)}))}}}}}function I(){return{types:p,json:{write:{target:"drawingInfo.renderer",ignoreOrigin:!0}}}}function _(e,i){e?.forEach(e=>{e.layer=i})}function v(e){let i=e.json;i||(i=e.json={});let r=i.write;return null!=r&&"object"==typeof r||(r=i.write={}),r.ignoreOrigin=!0,e}export{d as fieldConfigurationsProperty,c as fieldsIndexProperty,m as fieldsProperty,j as labelingInfoProperty,y as labelsVisibleProperty,h as layerProperty,w as maxScaleProperty,O as popupEnabledProperty,b as popupTemplateProperty,I as rendererProperty};
