/* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
import{substitute as e}from"../../intl.js";import{ReactiveGraphic as i}from"./ReactiveGraphic.js";import{getIntlOptionsForField as n}from"../support/dateUtils.js";import{getRangeErrorMessage as t,shouldUseScientificNotation as r,scientificNumberFormatOptions as o,numberFormatOptions as a}from"../support/forms/formUtils.js";const l=(e,i)=>null!=e&&e.input?.type===i;function s(e){return new i({source:e})}function d(i,l,s,d){const{dataType:u,minLength:p}=i,c=s?.validationErrors;if(!c||!l)return null;if("batch-attribute-form-validation::features-have-different-errors"===l)return c.invalidBatchFormType;if("input-validation-error::cannot-be-empty"===l)return c.cannotBeNull;if("domain-validation-error::value-out-of-range"===l||"numeric-range-validation-error::out-of-range"===l){const{field:l,range:s}=i,p={type:"date",intlOptions:{timeZone:"date"===l.type&&d?d:void 0,...n(l)}},f=t(s,c);return e(f,s,{format:{max:"date"===u?p:null!=s.max&&r(s.max)?o:a,min:"date"===u?p:null!=s.min&&r(s.min)?o:a}})}return"domain-validation-error::invalid-coded-value"===l?c.invalidCodedValue:"type-validation-error::invalid-type"===l?c.invalidType:"length-validation-error::too-short"===l?e(c.tooShort,{min:p}):null}function u(e,i,n){const t=n?.validationErrors;if(!t)return null;let r=null;for(const o of e.invalidHiddenInputs)switch(o.effectiveVisibilityCode){case"hidden:visibility-expression:all-features":case"hidden:group-visibility-expression:all-features":case"hidden:field-definition":return"single"===i?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":r=t.nonVisibleError_checkIndividualFeatures;break;case"visible":continue;default:o.effectiveVisibilityCode}return r}function p(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{s as createReactiveGraphic,u as getHiddenFieldsValidationErrorMessage,d as getVisibleFieldInputValidationErrorMessage,p as isAttributeFormSupportedLayerUnion,l as isElementTemplateWithInputType};
