{"version":3,"sources":["webpack:///./node_modules/@arcgis/core/layers/graphics/editingSupport.js"],"names":["n","e","applyEdits","async","l","t","a","i","s","d","edits","result","Promise","emit","results","o","filter","error","map","r","u","addedFeatures","addFeatureResults","updatedFeatures","updateFeatureResults","deletedFeatures","deleteFeatureResults","addedAttachments","addAttachmentResults","updatedAttachments","updateAttachmentResults","deletedAttachments","deleteAttachmentResults","editedFeatureResults","length","editedFeatures","load","type","layer","editingEnabled","options","addFeatures","updateFeatures","deleteFeatures","addAttachments","updateAttachments","deleteAttachments","capabilities","data","isVersioned","gdbVersion","editing","supportsRollbackOnFailure","rollbackOnFailureEnabled","supportsGlobalId","globalIdUsed","returnServiceEditsOption","supportsReturnServiceEditsInSourceSpatialReference","returnServiceEditsInSourceSR","isCollection","toArray","operations","supportsAdd","supportsUpdate","supportsDelete","g","forEach","c","m","h","y","f","p","attributes","globalIdField","globalId","geometry","hasZ","supportsZ","hasM","supportsM","supportsGeometryUpdate","feature","attachment","uploadId","File","name","supportsUploadWithItemId","isBase64","concat","slice"],"mappings":"kHAAA,0IAI+U,SAASA,EAAEC,GAAG,OAAOA,GAAG,MAAMA,EAAEC,WAAWC,eAAeC,EAAEH,EAAEI,EAAEC,EAAEC,EAAE,IAAI,IAAIC,EAAEC,EAAE,MAAMT,EAAE,CAACU,MAAMJ,EAAEK,OAAO,IAAIC,QAAS,CAACX,EAAEI,KAAKG,EAAEP,EAAEQ,EAAEJ,KAAMJ,EAAEY,KAAK,cAAcb,GAAG,IAAG,MAAC,MAAMc,QAAQL,EAAEC,MAAMV,SAASe,EAAEd,EAAEI,EAAEC,EAAEC,GAAGH,EAAEH,GAAGA,EAAEe,OAAQf,IAAIA,EAAEgB,OAAQC,IAAIC,QAAGC,EAAE,CAACV,MAAMV,EAAEqB,cAAcjB,EAAEK,EAAEa,mBAAmBC,gBAAgBnB,EAAEK,EAAEe,sBAAsBC,gBAAgBrB,EAAEK,EAAEiB,sBAAsBC,iBAAiBvB,EAAEK,EAAEmB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EAAEgC,KAAJ,2BAAmC,+CAA+C,KAAK9B,EAAEyC,gBAAgBqC,MAAQ9E,EAAEyC,KAAKsC,QAAQ/E,EAAE+E,KAAK,MAAM,IAAIhF,OAAKD,EAAEgC,KAAJ,2BAAmC,yFAAyF,IAAIhC,EAAE0C,aAAaI,QAAQoC,0BAA0BhF,EAAE6E,SAAS,MAAM,IAAI9E,OAAKD,EAAEgC,KAAJ,2BAAmC,0GAA0G,GAAG,iBAAiB9B,EAAEyC,KAAK,CAAC,MAAM/C,EAAEO,eAAED,EAAEyC,MAAM,GAAG/C,IAAIA,EAAEuF,SAAS,MAAM,IAAIlF,OAAKD,EAAEgC,KAAJ,2BAAmC,sEAAsElC,eAAeoE,EAAEtE,GAAG,MAAMI,EAAEJ,EAAEwC,YAAYnC,EAAEL,EAAEyC,eAAevB,EAAEd,EAAEoF,OAAOnF,GAAGY,IAAKjB,GAAGA,EAAE2E,UAAWrE,QAAQE,eAAEU,GAAGX,EAAEH,EAAE6B,OAAOlC,EAAEM,EAAE4B,OAAO,OAAO3B,EAAEmF,MAAM,EAAElF,GAAG0D,QAAS,CAAC7D,EAAEC,IAAIL,EAAEwC,YAAYnC,GAAGsE,SAASvE,GAAIE,EAAEmF,MAAMlF,EAAEA,EAAER,GAAGkE,QAAS,CAAC7D,EAAEC,IAAIL,EAAEyC,eAAepC,GAAGsE,SAASvE,GAAIJ,EAAE,SAASgE,EAAE5D,GAAG,MAAMC,EAAE,IAAIL,OAAE,OAAOI,EAAEoE,aAAapE,EAAEoE,WAAW,IAAInE,EAAEsE,SAASvE,EAAEuE,SAAStE,EAAEmE,WAAWpE,EAAEoE,WAAWnE","file":"js/chunk-2d0a4c1e.1afca38b.js","sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.24/esri/copyright.txt for details.\n*/\nimport e from\"../../Graphic.js\";import t from\"../../core/Collection.js\";import a from\"../../core/Error.js\";import{clone as r}from\"../../core/lang.js\";import{isSome as i}from\"../../core/maybe.js\";import{dataComponents as s}from\"../../core/urlUtils.js\";import{normalizeCentralMeridian as d}from\"../../geometry/support/normalizeUtils.js\";function n(e){return e&&null!=e.applyEdits}async function l(e,t,a,i={}){let s,d;const n={edits:a,result:new Promise(((e,t)=>{s=e,d=t}))};e.emit(\"apply-edits\",n);try{const{results:d,edits:n}=await o(e,t,a,i),l=e=>e.filter((e=>!e.error)).map(r),u={edits:n,addedFeatures:l(d.addFeatureResults),updatedFeatures:l(d.updateFeatureResults),deletedFeatures:l(d.deleteFeatureResults),addedAttachments:l(d.addAttachmentResults),updatedAttachments:l(d.updateAttachmentResults),deletedAttachments:l(d.deleteAttachmentResults)};return d.editedFeatureResults?.length&&(u.editedFeatures=d.editedFeatureResults),(u.addedFeatures.length||u.updatedFeatures.length||u.deletedFeatures.length||u.addedAttachments.length||u.updatedAttachments.length||u.deletedAttachments.length)&&e.emit(\"edits\",u),s(u),d}catch(l){throw d(l),l}}async function o(e,t,r,i){if(await e.load(),!n(t))throw new a(`${e.type}-layer:no-editing-support`,\"Layer source does not support applyEdits capability\",{layer:e});if(!e.editingEnabled)throw new a(`${e.type}-layer:editing-disabled`,\"Editing is disabled for layer\",{layer:e});const{edits:s,options:d}=await u(e,r,i);return s.addFeatures.length||s.updateFeatures.length||s.deleteFeatures.length||s.addAttachments.length||s.updateAttachments.length||s.deleteAttachments.length?{edits:s,results:await t.applyEdits(s,d)}:{edits:s,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}async function u(e,r,i){const s=r&&(r.addFeatures||r.updateFeatures||r.deleteFeatures),d=r&&(r.addAttachments||r.updateAttachments||r.deleteAttachments);if(!r||!s&&!d)throw new a(`${e.type}-layer:missing-parameters`,\"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required\");if(!e.capabilities.data.isVersioned&&i&&i.gdbVersion)throw new a(`${e.type}-layer:invalid-parameter`,\"'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'\");if(!e.capabilities.editing.supportsRollbackOnFailure&&i&&i.rollbackOnFailureEnabled)throw new a(`${e.type}-layer:invalid-parameter`,\"This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'\");if(!e.capabilities.editing.supportsGlobalId&&i&&i.globalIdUsed)throw new a(`${e.type}-layer:invalid-parameter`,\"This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'\");if(!e.capabilities.editing.supportsGlobalId&&d)throw new a(`${e.type}-layer:invalid-parameter`,\"'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'\");if((!i||!i.globalIdUsed)&&d)throw new a(`${e.type}-layer:invalid-parameter`,\"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true\");const n={...i};if(null!=n.rollbackOnFailureEnabled||e.capabilities.editing.supportsRollbackOnFailure||(n.rollbackOnFailureEnabled=!0),!1===n.rollbackOnFailureEnabled&&\"original-and-current-features\"===n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,\"'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.\");if(!e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference&&n.returnServiceEditsInSourceSR)throw new a(`${e.type}-layer:invalid-parameter`,\"This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'\");if(n.returnServiceEditsInSourceSR&&\"original-and-current-features\"!==n.returnServiceEditsOption)throw new a(`${e.type}-layer:invalid-parameter`,\"'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'\");const l={...r};if(l.addFeatures=r&&t.isCollection(r.addFeatures)?r.addFeatures.toArray():l.addFeatures||[],l.updateFeatures=r&&t.isCollection(r.updateFeatures)?r.updateFeatures.toArray():l.updateFeatures||[],l.deleteFeatures=r&&t.isCollection(r.deleteFeatures)?r.deleteFeatures.toArray():l.deleteFeatures||[],l.addFeatures.length&&!e.capabilities.operations.supportsAdd)throw new a(`${e.type}-layer:unsupported-operation`,\"Layer does not support adding features.\");if(l.updateFeatures.length&&!e.capabilities.operations.supportsUpdate)throw new a(`${e.type}-layer:unsupported-operation`,\"Layer does not support updating features.\");if(l.deleteFeatures.length&&!e.capabilities.operations.supportsDelete)throw new a(`${e.type}-layer:unsupported-operation`,\"Layer does not support deleting features.\");l.addAttachments=l.addAttachments||[],l.updateAttachments=l.updateAttachments||[],l.deleteAttachments=l.deleteAttachments||[],l.addFeatures=l.addFeatures.map(g),l.updateFeatures=l.updateFeatures.map(g);const o=i&&i.globalIdUsed;l.addFeatures.forEach((t=>c(t,e,o))),l.updateFeatures.forEach((t=>m(t,e,o))),l.deleteFeatures.forEach((t=>h(t,e,o))),l.addAttachments.forEach((t=>y(t,e))),l.updateAttachments.forEach((t=>y(t,e)));return{edits:await f(l),options:n}}function p(e,t,r){if(r){if(\"attributes\"in e&&!e.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,\"Feature should have 'globalId' when 'globalIdUsed' is true\");if(!(\"attributes\"in e)&&!e.globalId)throw new a(`${t.type}-layer:invalid-parameter`,\"'globalId' of the feature should be passed when 'globalIdUsed' is true\")}if(\"geometry\"in e&&i(e.geometry)){if(e.geometry.hasZ&&!1===t.capabilities.data.supportsZ)throw new a(`${t.type}-layer:z-unsupported`,\"Layer does not support z values while feature has z values.\");if(e.geometry.hasM&&!1===t.capabilities.data.supportsM)throw new a(`${t.type}-layer:m-unsupported`,\"Layer does not support m values while feature has m values.\")}}function c(e,t,a){p(e,t,a)}function h(e,t,a){p(e,t,a)}function m(e,t,r){if(p(e,t,r),\"geometry\"in e&&i(e.geometry)&&!t.capabilities.editing.supportsGeometryUpdate)throw new a(`${t.type}-layer:unsupported-operation`,\"Layer does not support geometry updates.\")}function y(e,t){const{feature:r,attachment:i}=e;if(!r||\"attributes\"in r&&!r.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have reference to a feature with 'globalId'\");if(!(\"attributes\"in r)&&!r.globalId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have reference to 'globalId' of the parent feature\");if(!i.globalId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have 'globalId'\");if(!i.data&&!i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have 'data' or 'uploadId'\");if(!(i.data instanceof File&&!!i.data.name)&&!i.name)throw new a(`${t.type}-layer:invalid-parameter`,\"'name' is required when attachment is specified as Base64 encoded string using 'data'\");if(!t.capabilities.editing.supportsUploadWithItemId&&i.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,\"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'\");if(\"string\"==typeof i.data){const e=s(i.data);if(e&&!e.isBase64)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment 'data' should be a Blob, File or Base64 encoded string\")}}async function f(e){const t=e.addFeatures,a=e.updateFeatures,r=t.concat(a).map((e=>e.geometry)),i=await d(r),s=t.length,n=a.length;return i.slice(0,s).forEach(((t,a)=>e.addFeatures[a].geometry=t)),i.slice(s,s+n).forEach(((t,a)=>e.updateFeatures[a].geometry=t)),e}function g(t){const a=new e;return t.attributes||(t.attributes={}),a.geometry=t.geometry,a.attributes=t.attributes,a}export{l as applyEdits};\n"],"sourceRoot":""}