{"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","u","filter","error","map","p","addedFeatures","addFeatureResults","updatedFeatures","updateFeatureResults","deletedFeatures","deleteFeatureResults","addedAttachments","addAttachmentResults","updatedAttachments","updateAttachmentResults","deletedAttachments","deleteAttachmentResults","editedFeatureResults","length","editedFeatures","r","load","reject","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","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,QAAQ,CAAEX,EAAEI,KAAKG,EAAEP,EAAEQ,EAAEJ,KAAMJ,EAAEY,KAAK,cAAcb,GAAG,IAAI,IAAII,EAAE,MAAMU,QAAQL,EAAEC,MAAMV,SAASe,EAAEd,EAAEI,EAAEC,EAAEC,GAAGS,EAAEf,GAAGA,EAAEgB,OAAQhB,IAAIA,EAAEiB,OAAQC,IAAI,QAAGC,EAAE,CAACV,MAAMV,EAAEqB,cAAcL,EAAEP,EAAEa,mBAAmBC,gBAAgBP,EAAEP,EAAEe,sBAAsBC,gBAAgBT,EAAEP,EAAEiB,sBAAsBC,iBAAiBX,EAAEP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C,MAAQ/E,EAAE2C,KAAKqC,QAAQhF,EAAEgF,KAAK,MAAM,IAAI,OAAKlF,EAAEkC,KAAL,2BAAoC,yFAAyF,IAAIlC,EAAE4C,aAAaI,QAAQmC,0BAA0BjF,EAAE8E,SAAS,MAAM,IAAI,OAAKhF,EAAEkC,KAAL,2BAAoC,0GAA0G,GAAG,iBAAiBhC,EAAE2C,KAAK,CAAC,MAAMjD,EAAE,eAAEM,EAAE2C,MAAM,GAAGjD,IAAIA,EAAEwF,SAAS,MAAM,IAAI,OAAKpF,EAAEkC,KAAL,2BAAoC,sEAAsEpC,eAAesE,EAAExE,GAAG,MAAMI,EAAEJ,EAAE0C,YAAYrC,EAAEL,EAAE2C,eAAeR,EAAE/B,EAAEqF,OAAOpF,GAAGa,IAAKlB,GAAGA,EAAE4E,UAAWtE,QAAQ,eAAE6B,GAAG5B,EAAEH,EAAE6B,OAAOlC,EAAEM,EAAE4B,OAAO,OAAO3B,EAAEoF,MAAM,EAAEnF,GAAG4D,QAAQ,CAAE/D,EAAEC,IAAIL,EAAE0C,YAAYrC,GAAGuE,SAASxE,GAAIE,EAAEoF,MAAMnF,EAAEA,EAAER,GAAGoE,QAAQ,CAAE/D,EAAEC,IAAIL,EAAE2C,eAAetC,GAAGuE,SAASxE,GAAIJ,EAAE,SAASkE,EAAE9D,GAAG,MAAMC,EAAE,IAAI,OAAE,OAAOD,EAAEqE,aAAarE,EAAEqE,WAAW,IAAIpE,EAAEuE,SAASxE,EAAEwE,SAASvE,EAAEoE,WAAWrE,EAAEqE,WAAWpE","file":"js/chunk-2d0a4c1e.a14d40e5.js","sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.21/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{var l;const{results:d,edits:n}=await o(e,t,a,i),u=e=>e.filter((e=>!e.error)).map(r),p={edits:n,addedFeatures:u(d.addFeatureResults),updatedFeatures:u(d.updateFeatureResults),deletedFeatures:u(d.deleteFeatureResults),addedAttachments:u(d.addAttachmentResults),updatedAttachments:u(d.updateAttachmentResults),deletedAttachments:u(d.deleteAttachmentResults)};return null!=(l=d.editedFeatureResults)&&l.length&&(p.editedFeatures=d.editedFeatureResults),(p.addedFeatures.length||p.updatedFeatures.length||p.deletedFeatures.length||p.addedAttachments.length||p.updatedAttachments.length||p.deletedAttachments.length)&&e.emit(\"edits\",p),s(p),d}catch(u){throw d(u),u}}async function o(e,t,r,i){if(await e.load(),!n(t))return Promise.reject(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":""}