/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{getFeatureEditFields as e,fixFields as l}from"../../../layers/support/fieldUtils.js";async function p(p,n=p.popupTemplate){if(null==n)return[];const u=await n.getRequiredFields(p.fieldsIndex),{lastEditInfoEnabled:t}=n,{objectIdField:d,typeIdField:a,globalIdField:i,relationships:o}=p;if(u.includes("*"))return["*"];const s=t?e(p):[],f=l(p.fieldsIndex,[...u,...s]);return a&&f.push(a),f&&d&&p.fieldsIndex?.has(d)&&!f.includes(d)&&f.push(d),f&&i&&p.fieldsIndex?.has(i)&&!f.includes(i)&&f.push(i),o?.forEach(e=>{const{keyField:l}=e;f&&l&&p.fieldsIndex?.has(l)&&!f.includes(l)&&f.push(l)}),f}function n(e,l){return e&&"object"==typeof e?l?.checkPopupEnabled&&"popupEnabled"in e&&!e.popupEnabled?null:"popupTemplate"in e&&e.popupTemplate?e.popupTemplate:null!=l&&l.defaultPopupTemplateEnabled&&"defaultPopupTemplate"in e&&e.defaultPopupTemplate?e.defaultPopupTemplate:null:null}function u(e,l){return null!=n(e,{defaultPopupTemplateEnabled:l})}export{n as getFetchPopupTemplate,p as getRequiredFields,u as hasPopupTemplate};
