/*
All material copyright Esri, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
*/
import{substitute as e}from"../../intl.js";import{neverReached as i}from"../../core/compilerUtils.js";import{ReactiveGraphic as n}from"./ReactiveGraphic.js";import{getIntlOptionsForField as r}from"../support/dateUtils.js";import{getRangeErrorMessage as t,shouldUseScientificNotation as o,scientificNumberFormatOptions as a,numberFormatOptions as l}from"../support/forms/formUtils.js";const s=(e,i)=>null!=e&&e.input?.type===i;function d(e){return new n({source:e})}function u(i,n,s,d){const{dataType:u,minLength:p}=i,c=s?.validationErrors;if(!c||!n)return null;if("batch-attribute-form-validation::features-have-different-errors"===n)return c.invalidBatchFormType;if("input-validation-error::cannot-be-empty"===n)return c.cannotBeNull;if("domain-validation-error::value-out-of-range"===n||"numeric-range-validation-error::out-of-range"===n){const{field:n,range:s}=i,p={type:"date",intlOptions:{timeZone:"date"===n.type&&d?d:void 0,...r(n)}},f=t(s,c);return e(f,s,{format:{max:"date"===u?p:null!=s.max&&o(s.max)?a:l,min:"date"===u?p:null!=s.min&&o(s.min)?a:l}})}return"domain-validation-error::invalid-coded-value"===n?c.invalidCodedValue:"type-validation-error::invalid-type"===n?c.invalidType:"length-validation-error::too-short"===n?e(c.tooShort,{min:p}):null}function p(e,n,r){const t=r?.validationErrors;if(!t)return null;let o=null;for(const a of e.invalidHiddenInputs)switch(a.effectiveVisibilityCode){case"hidden:visibility-expression:all-features":case"hidden:group-visibility-expression:all-features":case"hidden:field-definition":return"single"===n?t.nonVisibleError_changeValues:t.nonVisibleError_checkIndividualFeatures;case"hidden:no-domain-in-common":case"hidden:visibility-expression:some-features":case"hidden:group-visibility-expression:some-features":case"hidden:not-in-all-layers":o=t.nonVisibleError_checkIndividualFeatures;break;case"visible":continue;default:i(a.effectiveVisibilityCode)}return o}function c(e){return null!=e&&"object"==typeof e&&"type"in e&&("feature"===e.type||"geojson"===e.type||"knowledge-graph-sublayer"===e.type||"oriented-imagery"===e.type||"scene"===e.type||"subtype-sublayer"===e.type)}export{d as createReactiveGraphic,p as getHiddenFieldsValidationErrorMessage,u as getVisibleFieldInputValidationErrorMessage,c as isAttributeFormSupportedLayerUnion,s as isElementTemplateWithInputType};
