{"version":3,"sources":["webpack:///./node_modules/@arcgis/core/layers/graphics/editingSupport.js"],"names":["l","e","t","a","capabilities","operations","supportsEditing","editingEnabled","n","applyEdits","async","o","r","s","d","i","edits","result","Promise","emit","results","p","filter","error","map","addedFeatures","addFeatureResults","updatedFeatures","updateFeatureResults","deletedFeatures","deleteFeatureResults","addedAttachments","addAttachmentResults","updatedAttachments","updateAttachmentResults","deletedAttachments","deleteAttachmentResults","length","load","reject","type","layer","u","addFeatures","updateFeatures","deleteFeatures","addAttachments","updateAttachments","deleteAttachments","data","isVersioned","gdbVersion","editing","supportsRollbackOnFailure","rollbackOnFailureEnabled","supportsGlobalId","globalIdUsed","isCollection","toArray","supportsAdd","supportsUpdate","supportsDelete","b","forEach","c","y","m","g","f","h","attributes","globalIdField","globalId","geometry","hasZ","supportsZ","hasM","supportsM","supportsGeometryUpdate","feature","attachment","uploadId","File","name","supportsUploadWithItemId","isBase64","concat","slice"],"mappings":"kHAAA,0LAI+U,SAASA,EAAEC,GAAG,IAAIC,EAAEC,EAAE,OAAM,KAAM,MAAMF,GAAG,OAAOC,EAAED,EAAEG,eAAe,OAAOD,EAAED,EAAEG,iBAAY,EAAOF,EAAEG,kBAAkBL,MAAM,mBAAmBA,IAAIA,EAAEM,gBAAgB,SAASC,EAAEP,GAAG,OAAOA,GAAG,MAAMA,EAAEQ,WAAWC,eAAeC,EAAET,EAAEC,EAAES,EAAEC,GAAG,IAAIC,EAAEC,EAAE,MAAMf,EAAE,CAACgB,MAAMJ,EAAEK,OAAO,IAAIC,QAAQ,CAAEjB,EAAEC,KAAKY,EAAEb,EAAEc,EAAEb,KAAMA,EAAEiB,KAAK,cAAcnB,GAAG,IAAI,MAAMoB,QAAQL,EAAEC,MAAMhB,SAASqB,EAAEnB,EAAEC,EAAES,EAAEC,GAAGL,EAAEN,GAAGA,EAAEoB,OAAQrB,IAAIA,EAAEsB,OAAQC,IAAI,QAAGb,EAAE,CAACK,MAAMhB,EAAEyB,cAAcjB,EAAEO,E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EAAEoF,OAAOnF,GAAGqB,IAAKvB,GAAGA,EAAEwE,UAAW5D,QAAQ,eAAED,GAAGE,EAAEZ,EAAEmC,OAAOrC,EAAEG,EAAEkC,OAAO,OAAOxB,EAAE0E,MAAM,EAAEzE,GAAGiD,QAAQ,CAAE7D,EAAEC,KAAKF,EAAE0C,YAAYxC,GAAGsE,SAASvE,IAAKW,EAAE0E,MAAMzE,EAAEA,EAAEd,GAAG+D,QAAQ,CAAE7D,EAAEC,KAAKF,EAAE2C,eAAezC,GAAGsE,SAASvE,IAAKD,EAAE,SAAS6D,EAAE7D,GAAG,MAAMC,EAAE,IAAI,OAAE,OAAOD,EAAEqE,aAAarE,EAAEqE,WAAW,IAAIpE,EAAEuE,SAASxE,EAAEwE,SAASvE,EAAEoE,WAAWrE,EAAEqE,WAAWpE","file":"js/chunk-2d0a4c1e.5f9289b8.js","sourcesContent":["/*\nAll material copyright ESRI, All Rights Reserved, unless otherwise specified.\nSee https://js.arcgis.com/4.19/esri/copyright.txt for details.\n*/\nimport{clone as e}from\"../../core/lang.js\";import{isSome as t}from\"../../core/maybe.js\";import a from\"../../core/Error.js\";import{dataComponents as r}from\"../../core/urlUtils.js\";import s from\"../../core/Collection.js\";import d from\"../../Graphic.js\";import{normalizeCentralMeridian as i}from\"../../geometry/support/normalizeUtils.js\";function l(e){var t,a;return!0===(null==e||null==(t=e.capabilities)||null==(a=t.operations)?void 0:a.supportsEditing)&&e&&(!(\"editingEnabled\"in e)||e.editingEnabled)}function n(e){return e&&null!=e.applyEdits}async function o(t,a,r,s){let d,i;const l={edits:r,result:new Promise(((e,t)=>{d=e,i=t}))};t.emit(\"apply-edits\",l);try{const{results:i,edits:l}=await p(t,a,r,s),n=t=>t.filter((e=>!e.error)).map(e),o={edits:l,addedFeatures:n(i.addFeatureResults),updatedFeatures:n(i.updateFeatureResults),deletedFeatures:n(i.deleteFeatureResults),addedAttachments:n(i.addAttachmentResults),updatedAttachments:n(i.updateAttachmentResults),deletedAttachments:n(i.deleteAttachmentResults)};return(o.addedFeatures.length||o.updatedFeatures.length||o.deletedFeatures.length||o.addedAttachments.length||o.updatedAttachments.length||o.deletedAttachments.length)&&t.emit(\"edits\",o),d(o),i}catch(n){throw i(n),n}}async function p(e,t,r,s){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 d=await u(e,r,s);return d.addFeatures.length||d.updateFeatures.length||d.deleteFeatures.length||d.addAttachments.length||d.updateAttachments.length||d.deleteAttachments.length?{edits:d,results:await t.applyEdits(d,s)}:{edits:d,results:{addFeatureResults:[],updateFeatureResults:[],deleteFeatureResults:[],addAttachmentResults:[],updateAttachmentResults:[],deleteAttachmentResults:[]}}}function u(e,t,r){const d=t&&(t.addFeatures||t.updateFeatures||t.deleteFeatures),i=t&&(t.addAttachments||t.updateAttachments||t.deleteAttachments);if(!t||!d&&!i)throw new a(`${e.type}-layer:missing-parameters`,\"'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required\");if(!e.capabilities.data.isVersioned&&r&&r.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&&r&&r.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&&r&&r.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&&i)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((!r||!r.globalIdUsed)&&i)throw new a(`${e.type}-layer:invalid-parameter`,\"When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true\");const l={...t};if(l.addFeatures=t&&s.isCollection(t.addFeatures)?t.addFeatures.toArray():l.addFeatures||[],l.updateFeatures=t&&s.isCollection(t.updateFeatures)?t.updateFeatures.toArray():l.updateFeatures||[],l.deleteFeatures=t&&s.isCollection(t.deleteFeatures)?t.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(b),l.updateFeatures=l.updateFeatures.map(b);const n=r&&r.globalIdUsed;return l.addFeatures.forEach((t=>c(t,e,n))),l.updateFeatures.forEach((t=>y(t,e,n))),l.deleteFeatures.forEach((t=>m(t,e,n))),l.addAttachments.forEach((t=>g(t,e))),l.updateAttachments.forEach((t=>g(t,e))),f(l)}function h(e,r,s){if(s){if(\"attributes\"in e&&!e.attributes[r.globalIdField])throw new a(`${r.type}-layer:invalid-parameter`,\"Feature should have 'globalId' when 'globalIdUsed' is true\");if(!(\"attributes\"in e)&&!e.globalId)throw new a(`${r.type}-layer:invalid-parameter`,\"'globalId' of the feature should be passed when 'globalIdUsed' is true\")}if(\"geometry\"in e&&t(e.geometry)){if(e.geometry.hasZ&&!1===r.capabilities.data.supportsZ)throw new a(`${r.type}-layer:z-unsupported`,\"Layer does not support z values while feature has z values.\");if(e.geometry.hasM&&!1===r.capabilities.data.supportsM)throw new a(`${r.type}-layer:m-unsupported`,\"Layer does not support m values while feature has m values.\")}}function c(e,t,a){h(e,t,a)}function m(e,t,a){h(e,t,a)}function y(e,r,s){if(h(e,r,s),\"geometry\"in e&&t(e.geometry)&&!r.capabilities.editing.supportsGeometryUpdate)throw new a(`${r.type}-layer:unsupported-operation`,\"Layer does not support geometry updates.\")}function g(e,t){const{feature:s,attachment:d}=e;if(!s||\"attributes\"in s&&!s.attributes[t.globalIdField])throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have reference to a feature with 'globalId'\");if(!(\"attributes\"in s)&&!s.globalId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have reference to 'globalId' of the parent feature\");if(!d.globalId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have 'globalId'\");if(!d.data&&!d.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,\"Attachment should have 'data' or 'uploadId'\");if(!(d.data instanceof File&&!!d.data.name)&&!d.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&&d.uploadId)throw new a(`${t.type}-layer:invalid-parameter`,\"This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'\");if(\"string\"==typeof d.data){const e=r(d.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)),s=await i(r),d=t.length,l=a.length;return s.slice(0,d).forEach(((t,a)=>{e.addFeatures[a].geometry=t})),s.slice(d,d+l).forEach(((t,a)=>{e.updateFeatures[a].geometry=t})),e}function b(e){const t=new d;return e.attributes||(e.attributes={}),t.geometry=e.geometry,t.attributes=e.attributes,t}export{o as applyEdits,l as isEditableLayer};\n"],"sourceRoot":""}