/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["require","exports","../../../../chunks/_rollupPluginBabelHelpers","../../../../core/maybe","../../../../geometry/support/spatialReferenceUtils","../../../support/fieldUtils"],(function(e,t,i,n,r,l){"use strict";let o=function(){this.code=null,this.description=null},s=function(e){this.error=new o,this.globalId=null,this.objectId=null,this.success=!1,this.uniqueId=null,this.error.description=e};function u(e){return new s(e)}let a=function(e){this.globalId=null,this.success=!0,this.objectId=this.uniqueId=e};function c(e){return new a(e)}const d=new Set;function f(e,t,i,n=!1,r){d.clear();for(const o in i){const s=e.get(o);if(!s)continue;const a=i[o],c=p(s,a);if(c!==a&&r&&r.push({name:"invalid-value-type",message:"attribute value was converted to match the field type",details:{field:s,originalValue:a,sanitizedValue:c}}),d.add(s.name),s&&(n||s.editable)){const e=l.validateFieldValue(s,c);if(e)return u(l.validationErrorToString(e,s,c));t[s.name]=c}}for(const l of e.requiredFields)if(!d.has(l.name))return u(`missing required field "${l.name}"`);return null}function p(e,t){let i=t;return"string"==typeof t&&l.isNumericField(e)?i=parseFloat(t):null!=t&&l.isStringField(e)&&"string"!=typeof t&&(i=String(t)),l.sanitizeNullFieldValue(i)}let y;function g(e,t){if(!e||!r.isValid(t))return e;if("rings"in e||"paths"in e){if(n.isNone(y))throw new TypeError("geometry engine not loaded");return y.simplify(t,e)}return e}function m(){return h.apply(this,arguments)}function h(){return(h=i._asyncToGenerator((function*(){return n.isNone(y)&&(y=yield new Promise(((t,i)=>e(["../../../../geometry/geometryEngineJSON"],t,i)))),y}))).apply(this,arguments)}function b(e,t){return F.apply(this,arguments)}function F(){return(F=i._asyncToGenerator((function*(e,t){!r.isValid(e)||"esriGeometryPolygon"!==t&&"esriGeometryPolyline"!==t||(yield m())}))).apply(this,arguments)}t.createFeatureEditErrorResult=u,t.createFeatureEditSuccessResult=c,t.loadGeometryEngine=m,t.loadGeometryEngineForSimplify=b,t.mixAttributes=f,t.simplify=g,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
