featureLayerUtils-SGDU7QQB.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. import {
  2. i as i2
  3. } from "./chunk-5ZZSM3DU.js";
  4. import "./chunk-BQ7UE3XL.js";
  5. import {
  6. b as b2
  7. } from "./chunk-KA2TGIQA.js";
  8. import {
  9. a as a2,
  10. c,
  11. f,
  12. i
  13. } from "./chunk-UYC6KGJA.js";
  14. import {
  15. o
  16. } from "./chunk-ILURGS2L.js";
  17. import "./chunk-QNKN2AAB.js";
  18. import {
  19. Ke
  20. } from "./chunk-6NQ3AA2U.js";
  21. import "./chunk-524XACB7.js";
  22. import "./chunk-XKHC7KKF.js";
  23. import "./chunk-HGDNY7J3.js";
  24. import "./chunk-GD5TMIPM.js";
  25. import "./chunk-ZRX5UNQH.js";
  26. import "./chunk-VEAEIBHK.js";
  27. import "./chunk-6SASJ6IM.js";
  28. import "./chunk-3OHML7FO.js";
  29. import "./chunk-JGOAMEPM.js";
  30. import "./chunk-Z64YKYHD.js";
  31. import "./chunk-2VFJVI2I.js";
  32. import "./chunk-F37AVPUF.js";
  33. import "./chunk-FUEX356Y.js";
  34. import "./chunk-DH2OBAUC.js";
  35. import "./chunk-TNLRDNTC.js";
  36. import "./chunk-OSNKP4CI.js";
  37. import "./chunk-435DJNTD.js";
  38. import "./chunk-T3EUPDKL.js";
  39. import "./chunk-2SJEIKRW.js";
  40. import {
  41. a,
  42. l
  43. } from "./chunk-4FQG6M7Q.js";
  44. import "./chunk-PHRSJJ3U.js";
  45. import "./chunk-VVBOYBFX.js";
  46. import "./chunk-S7R5EXHN.js";
  47. import "./chunk-FMKGHOGD.js";
  48. import "./chunk-6URTNEGN.js";
  49. import "./chunk-KN7TOKVN.js";
  50. import "./chunk-RQJNTZAL.js";
  51. import "./chunk-QTOOFNRV.js";
  52. import "./chunk-7O56JPWQ.js";
  53. import "./chunk-6B2LQBKM.js";
  54. import "./chunk-MFI6BALW.js";
  55. import "./chunk-CIG5OHC7.js";
  56. import "./chunk-FUD7XO3N.js";
  57. import "./chunk-6EU7GFUT.js";
  58. import "./chunk-MFUAILAT.js";
  59. import "./chunk-HZJYXMI6.js";
  60. import "./chunk-27P5ZSC7.js";
  61. import "./chunk-UPD4MTCL.js";
  62. import "./chunk-GRBROWI6.js";
  63. import "./chunk-5NKYXKIA.js";
  64. import "./chunk-MPWGHCZG.js";
  65. import "./chunk-FTI5VP6T.js";
  66. import "./chunk-RZFGRBD7.js";
  67. import "./chunk-PUSPZYFZ.js";
  68. import "./chunk-EN7YGJWG.js";
  69. import "./chunk-VBNMTM7L.js";
  70. import "./chunk-3D3QEPRE.js";
  71. import "./chunk-JFNNSBWL.js";
  72. import "./chunk-UD63WBG3.js";
  73. import {
  74. m
  75. } from "./chunk-X7DBH4KK.js";
  76. import "./chunk-LY74KTXV.js";
  77. import "./chunk-EWE6EXPY.js";
  78. import "./chunk-KUXNUNAI.js";
  79. import "./chunk-KMAHKQ2G.js";
  80. import "./chunk-522WBHUO.js";
  81. import "./chunk-WNCU6BFU.js";
  82. import "./chunk-PIGRDDRG.js";
  83. import "./chunk-BJHM4JNS.js";
  84. import "./chunk-F6A2QQ26.js";
  85. import "./chunk-XLV7RUSE.js";
  86. import "./chunk-NTUXR253.js";
  87. import "./chunk-EOSZHC5H.js";
  88. import "./chunk-C43UE3Z5.js";
  89. import "./chunk-H2KDMZTR.js";
  90. import "./chunk-RMX2AZ4P.js";
  91. import "./chunk-NE3ESGA6.js";
  92. import "./chunk-YIS6BAC3.js";
  93. import "./chunk-7XXXCK2A.js";
  94. import "./chunk-7ZIDBK7B.js";
  95. import "./chunk-KHA63LLS.js";
  96. import "./chunk-FGKNEJKJ.js";
  97. import "./chunk-PSV473TI.js";
  98. import "./chunk-I3OBGWNS.js";
  99. import "./chunk-FONIFA5N.js";
  100. import "./chunk-EG5OI4V4.js";
  101. import "./chunk-65BYCSII.js";
  102. import "./chunk-WZQZRKNH.js";
  103. import "./chunk-LRDX4TO7.js";
  104. import "./chunk-6A4U74YA.js";
  105. import "./chunk-CYI7KFYB.js";
  106. import "./chunk-5LXROFTA.js";
  107. import "./chunk-GJXW4HL5.js";
  108. import "./chunk-WJW5DUN6.js";
  109. import "./chunk-W72F6AS3.js";
  110. import "./chunk-PJ7ZQ4VD.js";
  111. import "./chunk-WDLTDV2L.js";
  112. import "./chunk-TERAW6FT.js";
  113. import "./chunk-N2663GRX.js";
  114. import "./chunk-O4FY3ITT.js";
  115. import "./chunk-WEMIK25H.js";
  116. import "./chunk-4DDBH2K5.js";
  117. import "./chunk-7N4X6GF3.js";
  118. import "./chunk-JXW4QTJA.js";
  119. import "./chunk-UXF37FQ4.js";
  120. import "./chunk-ZOEK6QHJ.js";
  121. import "./chunk-XNLG7T2T.js";
  122. import "./chunk-IR4PV7VK.js";
  123. import "./chunk-2Z6LERTI.js";
  124. import "./chunk-OWVBLVP3.js";
  125. import "./chunk-AFZ7XSEW.js";
  126. import {
  127. b
  128. } from "./chunk-EGZW6HC3.js";
  129. import {
  130. B
  131. } from "./chunk-4NKD334K.js";
  132. import "./chunk-65K7LC56.js";
  133. import "./chunk-ATPLLI5W.js";
  134. import "./chunk-WJ3OEUD3.js";
  135. import "./chunk-MXB2XLKV.js";
  136. import "./chunk-XH7RUGVZ.js";
  137. import "./chunk-TBBTRX4O.js";
  138. import "./chunk-YBSUITLL.js";
  139. import "./chunk-ALDCDSPV.js";
  140. import "./chunk-DT6EAZQ5.js";
  141. import "./chunk-HNOZUNJ4.js";
  142. import "./chunk-VNFRAYHO.js";
  143. import "./chunk-R5IG2D6H.js";
  144. import "./chunk-VBRY5KJM.js";
  145. import "./chunk-PDKDCAAD.js";
  146. import "./chunk-ECW2QABR.js";
  147. import "./chunk-GCDJLKH4.js";
  148. import "./chunk-MRJEICT6.js";
  149. import "./chunk-Y3WMVFTW.js";
  150. import "./chunk-SAS7RONY.js";
  151. import "./chunk-WSRBH7BF.js";
  152. import "./chunk-IHXECKQQ.js";
  153. import {
  154. E,
  155. x
  156. } from "./chunk-ULGDPLM2.js";
  157. import {
  158. s as s2,
  159. s3
  160. } from "./chunk-EMJ4ZSM2.js";
  161. import "./chunk-IKP3YN53.js";
  162. import {
  163. r,
  164. s2 as s,
  165. t
  166. } from "./chunk-GZT4BVFP.js";
  167. import "./chunk-A5ICIBVI.js";
  168. // node_modules/@arcgis/core/layers/save/featureLayerUtils.js
  169. var I = s2.getLogger("esri.layers.FeatureLayer");
  170. var S = "Feature Service";
  171. function g(e, t2) {
  172. return `Layer (title: ${e.title}, id: ${e.id}) of type '${e.declaredClass}' ${t2}`;
  173. }
  174. function j(e, a3) {
  175. if (a3.type !== S)
  176. throw new s3("feature-layer:portal-item-wrong-type", g(e, `should have portal item of type "${S}"`));
  177. }
  178. async function L(e) {
  179. if (await e.load(), a(e))
  180. throw new s3("feature-layer:save", g(e, "using an in-memory source cannot be saved to a portal item"));
  181. }
  182. function P(e, a3) {
  183. let r2 = e.messages.filter(({ type: e2 }) => e2 === "error").map(({ name: e2, message: a4, details: r3 }) => new s3(e2, a4, r3));
  184. if (a3?.ignoreUnsupported && (r2 = r2.filter(({ name: e2 }) => e2 !== "layer:unsupported" && e2 !== "symbol:unsupported" && e2 !== "symbol-layer:unsupported" && e2 !== "property:unsupported" && e2 !== "url:unsupported")), r2.length > 0)
  185. throw new s3("feature-layer:save", "Failed to save feature layer due to unsupported or invalid content. See 'details.errors' for more detailed information", { errors: r2 });
  186. }
  187. async function J(e, t2, a3) {
  188. "beforeSave" in e && typeof e.beforeSave == "function" && await e.beforeSave();
  189. const r2 = e.write({}, t2);
  190. return P(t2, a3), r2;
  191. }
  192. function N(e) {
  193. const { layer: t2, layerJSON: a3 } = e;
  194. return t2.isTable ? { layers: [], tables: [a3] } : { layers: [a3], tables: [] };
  195. }
  196. function O(e) {
  197. i(e, f.JSAPI), e.typeKeywords && (e.typeKeywords = e.typeKeywords.filter((e2, t2, a3) => a3.indexOf(e2) === t2));
  198. }
  199. function E2(e) {
  200. const a3 = e.portalItem;
  201. if (!a3)
  202. throw I.error("save: requires the portalItem property to be set"), new s3("feature-layer:portal-item-not-set", g(e, "requires the portalItem property to be set"));
  203. if (!a3.loaded)
  204. throw new s3("feature-layer:portal-item-not-loaded", g(e, "cannot be saved to a portal item that does not exist or is inaccessible"));
  205. j(e, a3);
  206. }
  207. async function T(e, t2) {
  208. return /\/\d+\/?$/.test(e.url) ? N(t2[0]) : $(e, t2);
  209. }
  210. async function $(e, t2) {
  211. const { layer: { url: a3, customParameters: r2, apiKey: o2 } } = t2[0];
  212. let s4 = await e.fetchData("json");
  213. s4 && s4.layers != null && s4.tables != null || (s4 = await x2(s4, { url: a3, customParameters: r2, apiKey: o2 }, t2.map((e2) => e2.layer.layerId)));
  214. for (const l2 of t2)
  215. K(l2.layer, l2.layerJSON, s4);
  216. return s4;
  217. }
  218. async function x2(e, t2, a3) {
  219. var r2, o2;
  220. e || (e = {}), (r2 = e).layers || (r2.layers = []), (o2 = e).tables || (o2.tables = []);
  221. const { url: s4, customParameters: l2, apiKey: i3 } = t2, { serviceJSON: n, layersJSON: p } = await b2(s4, { customParameters: l2, apiKey: i3 }), c2 = A(e.layers, n.layers, a3), y = A(e.tables, n.tables, a3);
  222. e.layers = c2.itemResources, e.tables = y.itemResources;
  223. const d = [...c2.added, ...y.added], m2 = p ? [...p.layers, ...p.tables] : [];
  224. return await U(e, d, s4, m2), e;
  225. }
  226. function A(t2, a3, r2) {
  227. const o2 = s(t2, a3, (e, t3) => e.id === t3.id);
  228. t2 = t2.filter((e) => !o2.removed.some((t3) => t3.id === e.id));
  229. const s4 = o2.added.map(({ id: e }) => ({ id: e }));
  230. return s4.forEach(({ id: e }) => {
  231. t2.push({ id: e });
  232. }), { itemResources: t2, added: s4.filter(({ id: e }) => !r2.includes(e)) };
  233. }
  234. async function U(e, t2, a3, o2) {
  235. const s4 = t2.map(({ id: e2 }) => new Ke({ url: a3, layerId: e2, sourceJSON: o2.find(({ id: t3 }) => t3 === e2) }));
  236. await E(s4.map((e2) => e2.load())), s4.forEach((t3) => {
  237. const { layerId: a4, loaded: o3, defaultPopupTemplate: s5 } = t3;
  238. if (!o3 || t(s5))
  239. return;
  240. K(t3, { id: a4, popupInfo: s5.toJSON() }, e);
  241. });
  242. }
  243. function K(e, t2, a3) {
  244. e.isTable ? F(a3.tables, t2) : F(a3.layers, t2);
  245. }
  246. function F(e, t2) {
  247. const a3 = e.findIndex(({ id: e2 }) => e2 === t2.id);
  248. a3 === -1 ? e.push(t2) : e[a3] = t2;
  249. }
  250. function R(e) {
  251. const { portalItem: t2 } = e;
  252. return l(e) && !e.dynamicDataSource && !!t2?.loaded && t2.type === S;
  253. }
  254. async function D(e) {
  255. if (!e?.length)
  256. throw new s3("feature-layer-utils-saveall:missing-parameters", "'layers' array should contain at least one feature layer");
  257. await Promise.all(e.map((e2) => e2.load()));
  258. for (const o2 of e)
  259. if (!R(o2))
  260. throw new s3("feature-layer-utils-saveall:invalid-parameters", `'layers' array should only contain layers or tables in a feature service loaded from 'Feature Service' item. ${g(o2, "does not conform")}`, { layer: o2 });
  261. const a3 = e.map((e2) => e2.portalItem.id);
  262. if (new Set(a3).size > 1)
  263. throw new s3("feature-layer-utils-saveall:invalid-parameters", "All layers in the 'layers' array should be loaded from the same portal item");
  264. const r2 = e.map((e2) => e2.layerId);
  265. if (new Set(r2).size !== r2.length)
  266. throw new s3("feature-layer-utils-saveall:invalid-parameters", "'layers' array should contain only one instance each of layer or table in a feature service");
  267. }
  268. function _(e, t2) {
  269. var a3, r2;
  270. let o2 = b.from(t2);
  271. return o2.id && (o2 = o2.clone(), o2.id = null), (a3 = o2).type ?? (a3.type = S), (r2 = o2).portal ?? (r2.portal = B.getDefault()), j(e, o2), o2;
  272. }
  273. async function q(e, t2) {
  274. const { url: a3, layerId: r2, title: s4, fullExtent: l2, isTable: i3 } = e, n = m(a3), u = r(n) && n.serverType === "FeatureServer";
  275. t2.url = u ? a3 : `${a3}/${r2}`, t2.title || (t2.title = s4), t2.extent = null, !i3 && r(l2) && (t2.extent = await a2(l2)), c(t2, f.METADATA), c(t2, f.MULTI_LAYER), i(t2, f.SINGLE_LAYER), i3 && i(t2, f.TABLE), O(t2);
  276. }
  277. async function z(e, t2, a3) {
  278. const r2 = e.portal;
  279. await r2._signIn(), await r2.user.addItem({ item: e, data: t2, folder: a3?.folder });
  280. }
  281. var C = x(M);
  282. async function M(e, t2) {
  283. await L(e), E2(e);
  284. const a3 = e.portalItem, r2 = o(a3), o2 = await J(e, r2, t2), s4 = await T(a3, [{ layer: e, layerJSON: o2 }]);
  285. return O(a3), await a3.update({ data: s4 }), i2(r2), a3;
  286. }
  287. var Y = x(async (e, t2) => {
  288. await D(e);
  289. const a3 = e[0].portalItem, r2 = o(a3), o2 = await Promise.all(e.map((e2) => J(e2, r2, t2))), s4 = await T(a3, e.map((e2, t3) => ({ layer: e2, layerJSON: o2[t3] })));
  290. return O(a3), await a3.update({ data: s4 }), await Promise.all(e.slice(1).map((e2) => e2.portalItem.reload())), i2(r2), a3.clone();
  291. });
  292. var B2 = x(G);
  293. async function G(e, t2, a3) {
  294. await L(e);
  295. const r2 = _(e, t2), o2 = o(r2), s4 = N({ layer: e, layerJSON: await J(e, o2, a3) });
  296. return await q(e, r2), await z(r2, s4, a3), e.portalItem = r2, i2(o2), r2;
  297. }
  298. export {
  299. C as save,
  300. Y as saveAll,
  301. B2 as saveAs
  302. };
  303. //# sourceMappingURL=featureLayerUtils-SGDU7QQB.js.map