// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../chunks/tslib.es6 ../core/JSONSupport ../core/lang ../core/SetUtils ../core/accessorSupport/decorators/property ../core/accessorSupport/decorators/cast ../core/accessorSupport/decorators/reader ../core/accessorSupport/decorators/subclass ../core/accessorSupport/decorators/writer ./ExpressionInfo ./elements/GroupElement ./support/elements ./support/formUtils ../layers/support/fieldUtils".split(" "),function(g,e,v,m,k,y,z,A,B,C,D,n,p,h){function w(a,c,b){const {fieldsIndex:d}=c;if(!d||d.fields.length!== a.size)switch(l(a,d,b.label),l(a,d,b.description),b.type){case "field":h.collectField(a,d,b.fieldName);break;case "group":b.elements.forEach(f=>w(a,c,f));break;case "relationship":if(c.relationships){const f=c.relationships.find(q=>q.id===b.relationshipId);f&&h.collectField(a,d,f.keyField)}h.collectFields(a,d,b.orderByFields?.map(f=>f.field));break;case "text":l(a,d,b.text)}}function E(a,c){if(!c||0===c.length)return[];a=x(a);const b=[];for(const d of c)a.has(d.name)&&b.push(d.expression);return b} function x(a){const c=new Set;for(const b of a)if(m.addMaybe(c,b.visibilityExpression),!p.isTextElement(b))if(p.isGroupElement(b))m.addMany(c,x(b.elements));else if(m.addMaybe(c,b.editableExpression),p.isFieldElement(b)){const {requiredExpression:d,valueExpression:f}=b;m.addMany(c,[d,f])}return c}function l(a,c,b){h.collectFields(a,c,h.extractSubstitutionTemplatesFromString(b))}var r;const t=n.buildTypeMaps(D);e=r=class extends e.JSONSupport{constructor(a){super(a);this.expressionInfos=this.elements= this.description=null;this.preserveFieldValuesWhenHidden=!1;this.title=null}castElements(a){return n.ensureType(a,t)}readElements(a,c){return n.fromJSON(c.formElements,t)}writeElements(a,c){c.formElements=n.toJSON(a,t)}clone(){return new r({description:this.description,expressionInfos:v.clone(this.expressionInfos),elements:v.clone(this.elements),title:this.title,preserveFieldValuesWhenHidden:this.preserveFieldValuesWhenHidden})}async getFieldsUsed(a,c){const b=new Set,{description:d,elements:f,expressionInfos:q, title:F}=this;l(b,a,d);l(b,a,F);if(!f)return[];const G=E(f,q).map(u=>h.collectArcadeFieldNames(b,a,u));await Promise.all(G);for(const u of f)w(b,{fieldsIndex:a,relationships:c},u);return Array.from(b).sort()}};g.__decorate([k.property({type:String,json:{write:!0}})],e.prototype,"description",void 0);g.__decorate([k.property({json:{write:!0}})],e.prototype,"elements",void 0);g.__decorate([y.cast("elements")],e.prototype,"castElements",null);g.__decorate([z.reader("elements",["formElements"])],e.prototype, "readElements",null);g.__decorate([B.writer("elements")],e.prototype,"writeElements",null);g.__decorate([k.property({type:[C],json:{write:!0}})],e.prototype,"expressionInfos",void 0);g.__decorate([k.property({type:Boolean,json:{default:!1,write:!0}})],e.prototype,"preserveFieldValuesWhenHidden",void 0);g.__decorate([k.property({type:String,json:{write:!0}})],e.prototype,"title",void 0);return e=r=g.__decorate([A.subclass("esri.form.FormTemplate")],e)});