editingSupport-4UKFTNGT.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import {
  2. d,
  3. o
  4. } from "./chunk-IFWO6QLG.js";
  5. import {
  6. v
  7. } from "./chunk-WXUHXYJK.js";
  8. import "./chunk-NTERQTPO.js";
  9. import {
  10. n
  11. } from "./chunk-I4RYNNL6.js";
  12. import {
  13. g
  14. } from "./chunk-KJZ6SS3P.js";
  15. import "./chunk-OER54WCN.js";
  16. import "./chunk-HOCLACFL.js";
  17. import "./chunk-3MLCBRBA.js";
  18. import "./chunk-WTRZAXRY.js";
  19. import "./chunk-YMULPZCD.js";
  20. import "./chunk-NKMX5M3L.js";
  21. import "./chunk-VLG7MMVR.js";
  22. import "./chunk-TV3CFJQR.js";
  23. import "./chunk-4ONPMX2F.js";
  24. import "./chunk-47NSA4T4.js";
  25. import "./chunk-FUODOQDM.js";
  26. import "./chunk-SWMSD4RP.js";
  27. import "./chunk-UVVU4UUO.js";
  28. import "./chunk-X4SA4ELJ.js";
  29. import "./chunk-XJCUT65M.js";
  30. import "./chunk-PE24J2I5.js";
  31. import "./chunk-P3XKUGLS.js";
  32. import "./chunk-U7RKABRB.js";
  33. import "./chunk-X7CNGECX.js";
  34. import "./chunk-PSEI52P3.js";
  35. import "./chunk-5UVJ64RB.js";
  36. import "./chunk-AUOH2VSO.js";
  37. import "./chunk-ZYRIJWLX.js";
  38. import "./chunk-RYY6632W.js";
  39. import "./chunk-DW42UVIT.js";
  40. import "./chunk-TJNOJH33.js";
  41. import "./chunk-YAEIHDJH.js";
  42. import "./chunk-OSHI574D.js";
  43. import "./chunk-44GMIOGP.js";
  44. import "./chunk-75U5LM2V.js";
  45. import "./chunk-ZHRAUKVQ.js";
  46. import "./chunk-RZK6A2GY.js";
  47. import {
  48. j
  49. } from "./chunk-4NQ74ZR6.js";
  50. import "./chunk-X4LLOW7U.js";
  51. import "./chunk-BDA6VH2A.js";
  52. import "./chunk-Z4JTBD7M.js";
  53. import "./chunk-MSBIHK67.js";
  54. import "./chunk-HZRKBTHJ.js";
  55. import "./chunk-5DMBXPN2.js";
  56. import "./chunk-QANZ6BFY.js";
  57. import {
  58. nt
  59. } from "./chunk-VEGAOVMY.js";
  60. import "./chunk-CXCDYJ5R.js";
  61. import "./chunk-GAOW3WRZ.js";
  62. import "./chunk-QCKFNSN2.js";
  63. import "./chunk-6SOHRC7T.js";
  64. import "./chunk-U2XHEJM7.js";
  65. import "./chunk-SQOPWYIT.js";
  66. import "./chunk-6KZ2LTDA.js";
  67. import "./chunk-V6P2MAQQ.js";
  68. import {
  69. s3 as s
  70. } from "./chunk-E5O6P5I2.js";
  71. import {
  72. y
  73. } from "./chunk-SPWQ3AWG.js";
  74. import "./chunk-2TIUKVZN.js";
  75. import {
  76. r,
  77. t
  78. } from "./chunk-YXWMMD76.js";
  79. import "./chunk-S5KM4IGW.js";
  80. // node_modules/@arcgis/core/layers/support/infoFor3D.js
  81. var _;
  82. !function(_2) {
  83. _2.GLTF_BINARY = "3D_glb", _2.GLTF_JSON = "3D_gltf";
  84. }(_ || (_ = {}));
  85. // node_modules/@arcgis/core/layers/graphics/editingSupport.js
  86. function c(e) {
  87. return e && null != e.applyEdits;
  88. }
  89. async function h(e, t2, a, s2 = {}) {
  90. var _a;
  91. let i, o2;
  92. const d2 = { edits: a, result: new Promise((e2, t3) => {
  93. i = e2, o2 = t3;
  94. }) };
  95. e.emit("apply-edits", d2);
  96. try {
  97. const { results: o3, edits: d3 } = await m(e, t2, a, s2), n2 = (e2) => e2.filter((e3) => !e3.error).map(y), p = { edits: d3, addedFeatures: n2(o3.addFeatureResults), updatedFeatures: n2(o3.updateFeatureResults), deletedFeatures: n2(o3.deleteFeatureResults), addedAttachments: n2(o3.addAttachmentResults), updatedAttachments: n2(o3.updateAttachmentResults), deletedAttachments: n2(o3.deleteAttachmentResults) };
  98. return ((_a = o3.editedFeatureResults) == null ? void 0 : _a.length) && (p.editedFeatures = o3.editedFeatureResults), (p.addedFeatures.length || p.updatedFeatures.length || p.deletedFeatures.length || p.addedAttachments.length || p.updatedAttachments.length || p.deletedAttachments.length) && (e.emit("edits", p), o(e) && d.emit("edits", { layer: e, event: p })), i(p), o3;
  99. } catch (n2) {
  100. throw o2(n2), n2;
  101. }
  102. }
  103. async function m(e, t2, r2, s2) {
  104. if (await e.load(), !c(t2))
  105. throw new s(`${e.type}-layer:no-editing-support`, "Layer source does not support applyEdits capability", { layer: e });
  106. if (!e.editingEnabled)
  107. throw new s(`${e.type}-layer:editing-disabled`, "Editing is disabled for layer", { layer: e });
  108. const { edits: i, options: o2 } = await y2(e, r2, s2);
  109. return i.addFeatures.length || i.updateFeatures.length || i.deleteFeatures.length || i.addAttachments.length || i.updateAttachments.length || i.deleteAttachments.length ? { edits: i, results: await t2.applyEdits(i, o2) } : { edits: i, results: { addFeatureResults: [], updateFeatureResults: [], deleteFeatureResults: [], addAttachmentResults: [], updateAttachmentResults: [], deleteAttachmentResults: [] } };
  110. }
  111. async function y2(e, r2, i) {
  112. const o2 = r2 && (r2.addFeatures || r2.updateFeatures || r2.deleteFeatures), d2 = r2 && (r2.addAttachments || r2.updateAttachments || r2.deleteAttachments), n2 = r(e.infoFor3D);
  113. if (!r2 || !o2 && !d2)
  114. throw new s(`${e.type}-layer:missing-parameters`, "'addFeatures', 'updateFeatures', 'deleteFeatures', 'addAttachments', 'updateAttachments' or 'deleteAttachments' parameter is required");
  115. if (!e.capabilities.data.isVersioned && i && i.gdbVersion)
  116. throw new s(`${e.type}-layer:invalid-parameter`, "'gdbVersion' is applicable only if the layer supports versioned data. See: 'capabilities.data.isVersioned'");
  117. if (!e.capabilities.editing.supportsRollbackOnFailure && i && i.rollbackOnFailureEnabled)
  118. throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'rollbackOnFailureEnabled' parameter. See: 'capabilities.editing.supportsRollbackOnFailure'");
  119. if (!e.capabilities.editing.supportsGlobalId && i && i.globalIdUsed)
  120. throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'globalIdUsed' parameter. See: 'capabilities.editing.supportsGlobalId'");
  121. if (!e.capabilities.editing.supportsGlobalId && d2)
  122. throw new s(`${e.type}-layer:invalid-parameter`, "'addAttachments', 'updateAttachments' and 'deleteAttachments' are applicable only if the layer supports global ids. See: 'capabilities.editing.supportsGlobalId'");
  123. if ((!i || !i.globalIdUsed) && d2)
  124. throw new s(`${e.type}-layer:invalid-parameter`, "When 'addAttachments', 'updateAttachments' or 'deleteAttachments' is specified, globalIdUsed should be set to true");
  125. const l = { ...i };
  126. if (null != l.rollbackOnFailureEnabled || e.capabilities.editing.supportsRollbackOnFailure || (l.rollbackOnFailureEnabled = true), false === l.rollbackOnFailureEnabled && "original-and-current-features" === l.returnServiceEditsOption)
  127. throw new s(`${e.type}-layer:invalid-parameter`, "'original-and-current-features' is valid for 'returnServiceEditsOption' only when 'rollBackOnFailure' is true.");
  128. if (!e.capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference && l.returnServiceEditsInSourceSR)
  129. throw new s(`${e.type}-layer:invalid-parameter`, "This layer does not support 'returnServiceEditsInSourceSR' parameter. See: 'capabilities.editing.supportsReturnServiceEditsInSourceSpatialReference'");
  130. if (l.returnServiceEditsInSourceSR && "original-and-current-features" !== l.returnServiceEditsOption)
  131. throw new s(`${e.type}-layer:invalid-parameter`, "'returnServiceEditsOption' is valid only when 'returnServiceEditsOption' is set to 'original-and-current-features'");
  132. const u = { ...r2 };
  133. if (u.addFeatures = r2 && j.isCollection(r2.addFeatures) ? r2.addFeatures.toArray() : u.addFeatures || [], u.updateFeatures = r2 && j.isCollection(r2.updateFeatures) ? r2.updateFeatures.toArray() : u.updateFeatures || [], u.deleteFeatures = r2 && j.isCollection(r2.deleteFeatures) ? r2.deleteFeatures.toArray() : u.deleteFeatures || [], u.addFeatures.length && !e.capabilities.operations.supportsAdd)
  134. throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support adding features.");
  135. if (u.updateFeatures.length && !e.capabilities.operations.supportsUpdate)
  136. throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support updating features.");
  137. if (u.deleteFeatures.length && !e.capabilities.operations.supportsDelete)
  138. throw new s(`${e.type}-layer:unsupported-operation`, "Layer does not support deleting features.");
  139. u.addAttachments = u.addAttachments || [], u.updateAttachments = u.updateAttachments || [], u.deleteAttachments = u.deleteAttachments || [], u.addFeatures = u.addFeatures.map(v2), u.updateFeatures = u.updateFeatures.map(v2), u.addAssets = [];
  140. const p = i && i.globalIdUsed || n2;
  141. u.addFeatures.forEach((t2) => g2(t2, e, p)), u.updateFeatures.forEach((t2) => F(t2, e, p)), u.deleteFeatures.forEach((t2) => b(t2, e, p)), u.addAttachments.forEach((t2) => w(t2, e)), u.updateAttachments.forEach((t2) => w(t2, e)), n2 && await I(u, e);
  142. return { edits: await A(u), options: l };
  143. }
  144. function f(e, t2, r2) {
  145. if (r2) {
  146. if ("attributes" in e && !e.attributes[t2.globalIdField])
  147. throw new s(`${t2.type}-layer:invalid-parameter`, "Feature should have 'globalId' when 'globalIdUsed' is true");
  148. if (!("attributes" in e) && !e.globalId)
  149. throw new s(`${t2.type}-layer:invalid-parameter`, "'globalId' of the feature should be passed when 'globalIdUsed' is true");
  150. }
  151. if ("geometry" in e && r(e.geometry)) {
  152. if (e.geometry.hasZ && false === t2.capabilities.data.supportsZ)
  153. throw new s(`${t2.type}-layer:z-unsupported`, "Layer does not support z values while feature has z values.");
  154. if (e.geometry.hasM && false === t2.capabilities.data.supportsM)
  155. throw new s(`${t2.type}-layer:m-unsupported`, "Layer does not support m values while feature has m values.");
  156. }
  157. }
  158. function g2(e, t2, a) {
  159. f(e, t2, a);
  160. }
  161. function b(e, t2, a) {
  162. f(e, t2, a);
  163. }
  164. function F(e, t2, r2) {
  165. if (f(e, t2, r2), "geometry" in e && r(e.geometry) && !t2.capabilities.editing.supportsGeometryUpdate)
  166. throw new s(`${t2.type}-layer:unsupported-operation`, "Layer does not support geometry updates.");
  167. }
  168. function w(e, t2) {
  169. const { feature: r2, attachment: s2 } = e;
  170. if (!r2 || "attributes" in r2 && !r2.attributes[t2.globalIdField])
  171. throw new s(`${t2.type}-layer:invalid-parameter`, "Attachment should have reference to a feature with 'globalId'");
  172. if (!("attributes" in r2) && !r2.globalId)
  173. throw new s(`${t2.type}-layer:invalid-parameter`, "Attachment should have reference to 'globalId' of the parent feature");
  174. if (!s2.globalId)
  175. throw new s(`${t2.type}-layer:invalid-parameter`, "Attachment should have 'globalId'");
  176. if (!s2.data && !s2.uploadId)
  177. throw new s(`${t2.type}-layer:invalid-parameter`, "Attachment should have 'data' or 'uploadId'");
  178. if (!(s2.data instanceof File && !!s2.data.name) && !s2.name)
  179. throw new s(`${t2.type}-layer:invalid-parameter`, "'name' is required when attachment is specified as Base64 encoded string using 'data'");
  180. if (!t2.capabilities.editing.supportsUploadWithItemId && s2.uploadId)
  181. throw new s(`${t2.type}-layer:invalid-parameter`, "This layer does not support 'uploadId' parameter. See: 'capabilities.editing.supportsUploadWithItemId'");
  182. if ("string" == typeof s2.data) {
  183. const e2 = nt(s2.data);
  184. if (e2 && !e2.isBase64)
  185. throw new s(`${t2.type}-layer:invalid-parameter`, "Attachment 'data' should be a Blob, File or Base64 encoded string");
  186. }
  187. }
  188. async function A(e) {
  189. const t2 = e.addFeatures, a = e.updateFeatures, r2 = t2.concat(a).map((e2) => e2.geometry), s2 = await v(r2), i = t2.length, o2 = a.length;
  190. return s2.slice(0, i).forEach((t3, a2) => e.addFeatures[a2].geometry = t3), s2.slice(i, i + o2).forEach((t3, a2) => e.updateFeatures[a2].geometry = t3), e;
  191. }
  192. function v2(t2) {
  193. const a = new g();
  194. return t2.attributes || (t2.attributes = {}), a.geometry = t2.geometry, a.attributes = t2.attributes, a;
  195. }
  196. async function I(e, t2) {
  197. if (t(t2.infoFor3D))
  198. return;
  199. const { infoFor3D: a } = t2;
  200. let r2 = false;
  201. for (const i of a.editFormats)
  202. if (i === _.GLTF_BINARY) {
  203. r2 = true;
  204. break;
  205. }
  206. const s2 = [];
  207. for (const i of e.addFeatures)
  208. s2.push(E(i, e, t2, r2));
  209. for (const i of e.updateFeatures)
  210. s2.push(E(i, e, t2, r2));
  211. const o2 = await Promise.allSettled(s2);
  212. for (const i of o2)
  213. if ("rejected" === i.status)
  214. throw i.reason;
  215. }
  216. async function E(e, t2, r2, o2) {
  217. if (t(e.geometry) || "mesh" !== e.geometry.type)
  218. return;
  219. const n2 = e.geometry, l = r2.globalIdField;
  220. if (r(r2.parsedUrl) && r(n2.external) && Array.isArray(n2.external.source) && 1 === n2.external.source.length && "source" in n2.external.source[0] && "string" == typeof n2.external.source[0].source && n2.external.source[0].source.startsWith(r2.parsedUrl.path))
  221. return;
  222. if (!o2)
  223. throw new s(`${r2.type}-layer:binary-gltf-asset-not-supported`, "3DObjectFeatureLayer requires binary glTF (.glb) support for updating mesh geometry.");
  224. const u = await n2.toBinaryGLTF(), c2 = await u.buffer(), h2 = `{${n()}}`, m2 = `${h2}.glb`;
  225. t2.addAssets.push({ featureGlobalId: e.getAttribute(l), assetMapGlobalId: h2, assetName: m2, flags: 0, data: c2.data, mimeType: c2.type, assetType: _.GLTF_BINARY, feature: e });
  226. }
  227. export {
  228. h as applyEdits
  229. };
  230. //# sourceMappingURL=editingSupport-4UKFTNGT.js.map